Skip to content

Add comprehensive tool annotations #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,18 +718,37 @@ public record JsonSchema( // @formatter:off
* @param inputSchema A JSON Schema object that describes the expected structure of
* the arguments when calling this tool. This allows clients to validate tool
* arguments before sending them to the server.
* @param title A human-readable title for the tool. Intended for display purposes and
* not guaranteed to reflect actual tool behavior.
* @param readOnlyHint If true, the tool does not modify its environment. This is a
* hint and may not reflect the tool's actual behavior.
* @param destructiveHint If true, the tool may perform destructive updates to its
* environment if false, it only performs additive updates. Applicable only when
* {@code readOnlyHint == false}.
* @param idempotentHint If true, repeated calls to the tool with the same arguments
* have no additional effects. Applicable only when {@code readOnlyHint == false}.
* @param openWorldHint If true, the tool interacts with an open world of external
* entities (e.g., web search); if false, the domain is closed (e.g., memory tools).
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public record Tool( // @formatter:off
@JsonProperty("name") String name,
@JsonProperty("description") String description,
@JsonProperty("inputSchema") JsonSchema inputSchema) {
@JsonProperty("inputSchema") JsonSchema inputSchema,
@JsonProperty("title") String title,
@JsonProperty("readOnlyHint") Boolean readOnlyHint,
@JsonProperty("destructiveHint") Boolean destructiveHint,
@JsonProperty("idempotentHint") Boolean idempotentHint,
@JsonProperty("openWorldHint") Boolean openWorldHint) {

public Tool(String name, String description, String schema) {
this(name, description, parseSchema(schema));
this(name, description, parseSchema(schema), null, null, null, null, null);
}

public Tool(String name, String description, String schema, String title, Boolean readOnlyHint, Boolean destructiveHint, Boolean idempotentHint, Boolean openWorldHint) {
this(name, description, parseSchema(schema), title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint);
}

} // @formatter:on

private static JsonSchema parseSchema(String schema) {
Expand Down