ai newsFr., 4. Dez.
EilmeldungAlibaba Releases Qwen4-35B-A3B: Open-Weight MoE Model With 1M Context

MCP-Tool-Annotationen sollten standardmaessig "destructive" setzen

Wer MCP-Tools bei Claude oder ChatGPT einreicht, sollte Tool-Annotationen vorab bewusst konfigurieren. Der Entwickler von IndexCyborg, einem Remote-MCP-Server mit 36 Tools, berichtet aus der Einreichung in die Verzeichnisse von Claude und ChatGPT.

dev.toDonnerstag 15:00 · 03.12.DE6 Min. Lesezeit
Bild: dev.to

I build IndexCyborg, a tool that automates the indexing chores of a website. It has a remote MCP server with 36 tools, so people can ask Claude or ChatGPT things like "which of my pages aren't indexed, and why?".

In November we submitted it to the Claude connector directory and the ChatGPT app directory. Most of the review prep wasn't about OAuth or hosting. It was about four booleans per tool that we had half-ignored: the tool annotations. This post is what they mean, what their defaults say about your tools when you leave them out, and the one ChatGPT's scan caught us getting wrong.

A tool can carry annotations next to its name and schema. From the MCP schema:

Read the defaults as a sentence: a tool with no annotations may modify things, may destroy things, and talks to the outside world. That's the safe assumption for a client to make about a tool it knows nothing about, and it's the worst possible description of a list_websites tool.

Clients use these hints to decide what to show and when to ask the user for confirmation. If every tool looks destructive, either every call prompts, which trains users to click "Allow" without reading, or the client ignores the hints. Neither helps anyone.

The spec is blunt about this: annotations are not guaranteed to describe the tool faithfully, and clients should never make tool-use decisions based on annotations from untrusted servers.

So annotations are about the experience and the review, not about security. Our real enforcement is server-side: every tool runs through a wrapper that checks the caller's scope ( read, notify, manage, admin ) before the tool body runs:

With 36 tools, writing four booleans by hand on each one is how they drift. We use a handful of named presets:

// Every hint is set explicitly: ChatGPT's app review requires all three as booleans. export const READS = { readOnlyHint: true, destructiveHint: false, openWorldHint: false } as const; export const WRITES = { readOnlyHint: false, destructiveHint: false, openWorldHint: false } as const; // Safe to repeat: calling twice leaves the same state. export const WRITES_IDEMPOTENT = {... WRITES, idempotentHint: true } as const; // Reaches out to a third party (a website's DNS, Stripe, search engines, Google). // That includes reading the user's own website (sitemaps, pages): it is run by someone else. export const WRITES_EXTERNAL = {... WRITES, openWorldHint: true } as const; export const WRITES_IDEMPOTENT_EXTERNAL = {...

WRITES_IDEMPOTENT, openWorldHint: true } as const; export const DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, openWorldHint: false } as const; Enter fullscreen mode Exit fullscreen mode Each registration picks one, which makes the choice visible in review:

server. registerTool ( "get_unindexed_pages", { title: "Get unindexed pages", description: "List URLs Google has inspected and reported as currently not indexed", inputSchema: { website: websiteArg, limit: z. number ( ). int ( ). min ( 1 ). max ( 500 ). optional ( ) }, annotations: READS, }, async ( { website, limit } ) => run ( "read", async ( ) => { /*... */ } ) ); Enter fullscreen mode Exit fullscreen mode READS sets destructiveHint: false even though it's "only meaningful" for writing tools. That's deliberate: ChatGPT's review wanted readOnlyHint, destructiveHint and openWorldHint present as booleans on every tool, so we set all three everywhere rather than rely on a default that someone has to look up.

Our first version marked tools as open-world when they called a third-party API: IndexNow, Google, Stripe. Tools that only fetched the user's own website were "closed": it's their site, after all.

ChatGPT's tool scan disagreed and flagged four tools: discover_urls, add_website, register_urls and add_sitemap. All four fetch sitemaps and pages from the website being set up.

The scan was right. "Open world" isn't about whose account something belongs to, it's about whether the tool's input comes from a system you don't control. The user's website is run by someone else (their CMS, their host, whoever can edit a page) and its content is untrusted. A sitemap or a page can contain anything, including text written to steer an AI agent. A client that knows a tool reads the open web can treat its output with more suspicion.

The fix was one line per tool, from WRITES to WRITES_EXTERNAL. The lesson was the definition: if the tool reads or writes anything your server doesn't own, it's open world.

check_technical_seo returns the latest check for a URL, which is a read. It also has an optional queue_fresh_check flag that queues a new check, which is a write that fetches the page. Annotations describe a tool, not a call, so it's annotated WRITES_EXTERNAL.

If the pessimistic label hurts the common case, split the tool into a read and a write. We kept it as one because the write is rare and still harmless.

Our final split across 36 tools: 15 read-only, 5 destructive ( remove_website, disconnect_google, rotate_api_key, revoke_api_key, delete_api_key ), and everything else a non-destructive write.

MCP has two places for a display name: the tool's top-level title, and annotations.title. Claude's directory portal reads the second one. Rather than write each title twice, the server wraps registerTool once so every tool copies its title into its annotations:

function copyTitlesIntoAnnotations ( server: McpServer ): void { const register = server. registerTool. bind ( server ); server. registerTool = ( ( name: string, config: { title?: string; annotations?: object }, cb: unknown ) => register ( name, {... config, annotations: {... config. annotations, title: config. title } } as never, cb as never ) ) as typeof server. registerTool; } Enter fullscreen mode Exit fullscreen mode Make it a test Hints rot when someone adds a tool in a hurry, so the test suite connects a real MCP client to the server and checks every tool it lists:

it ( "set every annotation hint explicitly", async ( ) => { const client = await connect ( [ "read" ] ); const { tools } = await client. listTools ( ); for ( const tool of tools ) { expect ( typeof tool. title, tool. name ). toBe ( "string" ); expect ( tool. annotations?. title, tool. name ). toBe ( tool. title ); expect ( typeof tool. annotations?. readOnlyHint, tool. name ). toBe ( "boolean" ); expect ( typeof tool. annotations?. destructiveHint, tool. name ). toBe ( "boolean" ); expect ( typeof tool. annotations?. openWorldHint, tool. name ). toBe ( "boolean" ); } } ); Enter fullscreen mode Exit fullscreen mode Two more tests pin the exact lists of destructive and read-only tool names. Adding a destructive tool means changing a test on purpose, which is the point.

Briefly, because each could be its own post:

I wrote this with the help of an AI assistant, working from the project's commits and code. The snippets come from the repository, trimmed for length.

Originaltitel: MCP tool annotations default to "destructive": what we set before submitting to Claude and ChatGPTQuelle: dev.to (dev.to). Original öffnen