You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(mcp): trim SERVER_INSTRUCTIONS to lean on authoritative docs (koala73#3910)
* refactor(mcp): trim SERVER_INSTRUCTIONS to lean on authoritative docs
JMESPath and describe_tool stanzas previously inlined grammar / envelope /
quota detail that is now documented in docs/mcp-jmespath.mdx,
docs/mcp-error-catalog.mdx, and docs/mcp-tools-reference.mdx. Each
stanza collapses to one sentence stating the affordance + use case +
canonical-docs URL. Prompts and resources stanzas are unchanged.
initialize.result.instructions: 1945 B → 1397 B (-548 B / 28.2%) emitted
once per session. SERVER_VERSION 1.9.0 → 1.10.0; server-card.json synced;
version assertions in mcp-jmespath and mcp-tools-list-compression updated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(mcp): keep describe_tool 60/min + unknown-tool hint in-band
Greptile P2: the trimmed describe_tool stanza dropped two pieces of
load-bearing guidance — the 60/min rate-limit caveat that qualifies
"use freely", and the {error: 'unknown_tool', available: [...]}
self-correction hint. The block comment above SERVER_INSTRUCTIONS
explicitly says stanzas must stand alone because LLMs don't reliably
fetch URLs mid-session, so both belong in-band.
SERVER_INSTRUCTIONS: 1397 B → 1577 B (+180 B). Net trim vs pre-PR
baseline: 1945 B → 1577 B (-368 B / -18.9%). Version-history comment
updated with the corrected delta and rationale.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
// Session-level discovery instructions. Per MCP 2025-03-26 lifecycle spec,
223
242
// servers MAY return an `instructions` string in the `initialize` result;
224
-
// clients SHOULD surface this to the model. We carry the JMESPath contract
225
-
// (grammar URL, projection guide URL, limits) and the describe_tool affordance
226
-
// here — once per session — so per-tool advertisements stay terse. Worked
227
-
// examples used to live inline; they now live in docs/mcp-jmespath.mdx, which
228
-
// the LLM can fetch on demand instead of amortising ~500 bytes per session.
243
+
// clients SHOULD surface this to the model. Each stanza names an affordance
244
+
// (JMESPath, describe_tool, prompts/list, resources/list), states its one-line
245
+
// use case, and points at the authoritative docs URL for full detail — the
246
+
// LLM does not reliably fetch URLs mid-session, so the in-band sentences must
247
+
// stand alone. Inline guide/envelope detail used to live here; it now lives in
248
+
// docs/mcp-jmespath.mdx, docs/mcp-error-catalog.mdx, and
249
+
// docs/mcp-tools-reference.mdx, fetched on demand instead of amortising
250
+
// ~550 bytes per session.
229
251
exportconstSERVER_INSTRUCTIONS=[
230
-
'Every tool accepts an optional `jmespath` string argument. The server applies the expression server-side AFTER any per-tool filter/summary args, projecting the response before serialization. This is the single most effective way to reduce response tokens — typical 80-95% reduction when you only need a subset of fields.',
252
+
'Every tool accepts an optional `jmespath` string. Server-side projection applied AFTER per-tool filter/summary; typical 80-95% token reduction. Grammar: https://jmespath.org/specification.html. Guide + 12 worked examples: https://www.worldmonitor.app/docs/mcp-jmespath.',
'Guide with 12 worked examples against real response shapes: https://www.worldmonitor.app/docs/mcp-jmespath',
254
+
`Limits: expr ≤ ${JMESPATH_MAX_EXPR_BYTES}B, output ≤ ${JMESPATH_MAX_OUTPUT_BYTES}B. Bad expressions soft-fail via {_jmespath_error, original_keys} envelope (consumes one daily quota unit on retry — self-correct from original_keys). Full envelope reference: https://www.worldmonitor.app/docs/mcp-error-catalog.`,
234
255
'',
235
-
`Limits: expression ≤ ${JMESPATH_MAX_EXPR_BYTES} bytes; projected payload ≤ ${JMESPATH_MAX_OUTPUT_BYTES} bytes. Failures return {_jmespath_error, original_keys} inside the normal result envelope. Bad expressions DO consume one daily quota unit on retry — original_keys is echoed so you can self-correct in one extra call.`,
236
-
'',
237
-
`tools/list returns COMPRESSED tool descriptions (first sentence, ≤${TOOL_DESCRIPTION_MAX_BYTES}B per tool). Call describe_tool({tool_name}) to get the full uncompressed definition for any tool you're considering — especially useful when the compressed entry is ambiguous about behaviour or argument semantics. describe_tool is metadata-only and is EXEMPT from the Pro daily quota (still counts toward the 60/min rate limit), so use it freely while exploring. describe_tool({tool_name: 'nonexistent'}) returns {error: 'unknown_tool', available: [...]} so you can self-correct.`,
256
+
`tools/list ships compressed tool descriptions (≤${TOOL_DESCRIPTION_MAX_BYTES}B). Call describe_tool({tool_name}) for the full uncompressed definition — quota-exempt (still counts toward the 60/min rate limit), so use freely while exploring. describe_tool({tool_name: 'nonexistent'}) returns {error: 'unknown_tool', available: [...]} so you can self-correct. Full reference: https://www.worldmonitor.app/docs/mcp-tools-reference.`,
238
257
'',
239
258
'Issue prompts/list to discover pre-built workflow templates (country-briefing, energy-shock-watch, market-open-prep, conflict-pulse, route-risk-check, freshness-audit). Each prompt pre-bakes a JMESPath projection per step so the first execution lands on the right shape. prompts/list + prompts/get are quota-exempt (per-minute limit only).',
0 commit comments