-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Feature Request: Align MCP instructions with --tool-filter
Problem
When using --tool-filter to limit exposed tools, the MCP server correctly filters the tools available to the client. However, the server instructions sent via the MCP protocol still include documentation for ALL tool groups, regardless of the filter.
This means the AI client receives ~14,600 tokens of instructions in its system prompt, but ~8,800 tokens (61%) are for tool groups that aren't even exposed.
Example
Config:
{
"command": "npx",
"args": ["-y", "@neverinfamous/postgres-mcp", "--transport", "stdio", "--tool-filter", "starter,vector"],
"env": { ... }
}Tools exposed: 76/232 (correct — only starter + vector groups)
Instructions sent: ALL 25 sections including PostGIS, pgcrypto, ltree, citext, partitioning, pg_partman, pg_stat_kcache, cron, performance, monitoring, admin, backup, text, stats, introspection, migration — none of which have any tools exposed.
Impact
| Metric | Value |
|---|---|
| Total instruction tokens | ~14,600 |
| Useful (matching filter) | ~5,750 (39%) |
| Wasted (no matching tools) | ~8,850 (61%) |
| % of 200K context window | 4.4% wasted |
| % of 1M context window | 0.9% wasted |
For users on smaller context windows (200K), this is significant. The instructions block becomes the single largest component in the system prompt — larger than the user's project configuration and memory combined.
Proposed Solution
Align the instructions field sent during MCP initialization with the --tool-filter setting. Only include documentation sections for tool groups that have at least one tool exposed.
For example, with --tool-filter "starter,vector":
- Include: Critical Gotchas, Response Structures (filtered), API Mapping, Format Auto-Resolution, Vector Tools, JSONB Tools, Schema Tools, Transactions, Code Mode
- Exclude: Stats, Text, Performance, Monitoring, Admin, Backup, Partitioning, pg_partman, pg_stat_kcache, citext, ltree, PostGIS, Cron, pgcrypto, Introspection, Migration
This could also be a separate --instruction-filter flag for finer control.
Environment
@neverinfamous/postgres-mcpv2.3.0- Claude Code v2.1.75
- Transport: stdio