Skip to content

Enhancements to declarative API #77

@spericas

Description

@spericas

The following enhacements are suggested:

  1. When declaring a tool method, there should be a way to mark a param as required. For example,
    @Mcp.Tool("Adds a new event to the calendar")
    List<McpToolContent> addCalendarEvent(McpFeatures features,
                                          String name,                //  @Required?
                                          String date,                  //  @Required?
                                          List<String> attendees) {

By default all params are optional. The @Required annotation (or equivalent) should be used to generated the correct JSON schema for the tool.

  1. When binding template parameters, we currently use the method parameter name for binding. We should offer an alternative using an anntotation just like JAX-RS' @PathParam. We can still use our current approach by default.

  2. When binding completions, we should provide a way to bind both the name and the value (what the user has typed so far). We currently only provide the value. Some completions may use the value others may not. The workaround now is to inject the McpParameters and grab the name from there. Note that prompts typically have multiple fields that can be completed, so if the same completion method is used, it's important to get the name of the field being completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    declarativeChanges involved in declarativeenhancementNew feature or request

    Projects

    Status

    Normal priority

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions