Skip to content

Commit 0fd3dfc

Browse files
decofebrendanjryan
andauthored
fix(mcp): narrow Tempo Docs tool schema (#1230)
* fix(mcp): narrow Tempo Docs tool schema Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> * fix(mcp): annotate generated code tool --------- Co-authored-by: Brendan Ryan <1572504+brendanjryan@users.noreply.github.com>
1 parent f993b22 commit 0fd3dfc

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

apps/mcp-docs-indexer/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ The local `search` tool accepts Code Mode-friendly top-level controls:
7373
| `max_results` | Maximum chunks to return; defaults to `5` |
7474
| `max_chars_per_chunk` | Maximum compact text chars per chunk; defaults to `1200` |
7575
| `max_total_chars` | Maximum total compact chunk text chars; defaults to `2400` |
76-
| `include_raw` | Return full AI Search chunks instead of compact chunks |
7776
| `response_format` | Use `structured` to return data in MCP `structuredContent` with a short text summary |
7877

7978
When `source` and `sources` are omitted, the server applies a conservative
@@ -100,15 +99,16 @@ enters an MCP client's context window. Compact output also returns at most one
10099
chunk per page, preserving result diversity and avoiding repeated snippets from
101100
the same URL. Search text is bounded by `max_total_chars` after page
102101
deduplication, so broad searches cannot accidentally fill the client context
103-
with five large excerpts. Advanced `ai_search_options` are still accepted and
104-
normalized into the current AI Search binding shape.
102+
with five large excerpts. The public tool schema exposes only bounded,
103+
task-specific controls; upstream AI Search configuration and raw chunk
104+
responses are not advertised to MCP clients.
105105

106106
Pass `response_format: "structured"` on `search`, `find_pages`, or `read_page`
107107
when the client can read MCP `structuredContent`; this keeps the text content to
108108
a short status line while preserving the same machine-readable result object.
109109

110110
AI Search response caching is enabled by default with the `close_enough`
111-
threshold. Clients can override this with `ai_search_options.cache`.
111+
threshold.
112112
The Worker also keeps a small 60-second in-memory cache of successful search
113113
results per isolate to skip repeated AI Search round trips for identical
114114
normalized searches.

apps/mcp-docs-indexer/src/lib/mcp.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ describe('handleMcp', () => {
107107
body.result.tools.map((tool: { name: string }) => tool.name),
108108
).toEqual(['search', 'find_pages', 'read_page', 'code'])
109109
expect(body.result.tools[3].description).toContain('codemode.search')
110+
expect(body.result.tools[3].annotations).toEqual({
111+
destructiveHint: false,
112+
idempotentHint: true,
113+
openWorldHint: true,
114+
readOnlyHint: true,
115+
})
116+
expect(body.result.tools[0].inputSchema.properties).not.toHaveProperty(
117+
'include_raw',
118+
)
119+
expect(body.result.tools[0].inputSchema.properties).not.toHaveProperty(
120+
'ai_search_options',
121+
)
110122
})
111123

112124
it('normalizes simple source and result controls into retrieval options', async () => {

apps/mcp-docs-indexer/src/lib/mcp.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ async function listCodeTools(
378378
const codeServer = await createCodeServer(tools, context)
379379
return withMcpClient(codeServer, async (client) => {
380380
const result = await client.listTools()
381-
return result.tools
381+
return result.tools.map((tool) => ({
382+
...tool,
383+
annotations: READ_ONLY_TOOL_ANNOTATIONS,
384+
}))
382385
})
383386
}
384387

@@ -1484,15 +1487,6 @@ function toolSchemas(sources: Source[]): Tool[] {
14841487
minimum: 300,
14851488
maximum: 50000,
14861489
},
1487-
include_raw: {
1488-
type: 'boolean',
1489-
description: 'Return raw AI Search chunks.',
1490-
},
1491-
ai_search_options: {
1492-
type: 'object',
1493-
description: 'Advanced AI Search options.',
1494-
additionalProperties: true,
1495-
},
14961490
response_format: {
14971491
type: 'string',
14981492
enum: ['text', 'structured'],

0 commit comments

Comments
 (0)