Skip to content

Add tool annotations and server instructions - #31

Open
cmgeuze wants to merge 1 commit into
mainfrom
feat/tool-annotations-and-instructions
Open

Add tool annotations and server instructions#31
cmgeuze wants to merge 1 commit into
mainfrom
feat/tool-annotations-and-instructions

Conversation

@cmgeuze

@cmgeuze cmgeuze commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an optional IMCPToolAnnotations interface (implemented by TMCPToolBase and its two generic variants) with a MarkReadOnly(OpenWorld: Boolean = False) helper; tools/list includes readOnlyHint/openWorldHint for any tool that supports it, and leaves out annotations entirely for tools that don't, so this is backward compatible with any existing IMCPTool implementation.
  • Add TMCPSettings.Instructions (settings.ini: Server.Instructions), surfaced as the optional top-level instructions field of the initialize response per the MCP spec, omitted when empty.
  • Document both in the README and settings.ini.example.

Why

Per the spec, clients MAY add instructions to 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/dcc64 build of a consumer project (Context4D) against this branch, Debug and Release, Win32 and Win64
  • Consumer's own smoke test (stdio and Streamable HTTP transports) verifies instructions in initialize and readOnlyHint:true on every tool in tools/list
  • No automated tests in this repo itself (Windows + Delphi runner required, same as noted in consuming projects)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant