Add tool annotations and server instructions - #31
Open
cmgeuze wants to merge 1 commit into
Open
Conversation
Tools can now call MarkReadOnly to expose readOnlyHint/openWorldHint in tools/list, via a new IMCPToolAnnotations interface that TMCPToolBase and its two generic variants implement; tools/list adds the hints only when a tool supports the interface, so an IMCPTool built without the base classes is unaffected. TMCPSettings gains an Instructions property (settings.ini Server.Instructions, or set in code), surfaced as the optional "instructions" field of the initialize response per the MCP spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IMCPToolAnnotationsinterface (implemented byTMCPToolBaseand its two generic variants) with aMarkReadOnly(OpenWorld: Boolean = False)helper;tools/listincludesreadOnlyHint/openWorldHintfor any tool that supports it, and leaves outannotationsentirely for tools that don't, so this is backward compatible with any existingIMCPToolimplementation.TMCPSettings.Instructions(settings.ini:Server.Instructions), surfaced as the optional top-levelinstructionsfield of theinitializeresponse per the MCP spec, omitted when empty.settings.ini.example.Why
Per the spec, clients MAY add
instructionsto their system prompt and MAY use tool annotations to decide things like parallel execution or auto-approval of read-only calls. Several consuming projects (Context4D among them) expose only read-only, local lookups and want to say so explicitly instead of clients assuming the worst-case defaults.Test plan
dcc32/dcc64build of a consumer project (Context4D) against this branch, Debug and Release, Win32 and Win64instructionsininitializeandreadOnlyHint:trueon every tool intools/list