Skip to main content
Glama

mcp-lens

Progressive disclosure for large MCP tool catalogs.

CI License Python Spec Status

Quick Start · Spec · Examples · Contributing

Most MCP servers expose one tool per endpoint. That works until your catalog grows — 20 endpoints becomes 20 tool definitions loaded into every context window, 200 becomes 200, and the model starts guessing wrong between similarly-named tools long before you get there.

mcp-lens is a small, dependency-light pattern (and a Python reference implementation) for the alternative: expose exactly 3 stable meta-toolssearch_capabilities, get_capability_schema, execute_capability — no matter how many capabilities sit behind them. The tool-definition cost the model pays is O(1) in catalog size; only what search_capabilities actually returns grows with your catalog.

from mcp_lens import Capability, CapabilityRegistry, build_server

registry = CapabilityRegistry()
registry.register(
    Capability(
        key="billing.create_invoice",
        description="Create an invoice for a customer",
        input_schema={
            "type": "object",
            "properties": {"customer_id": {"type": "string"}, "amount": {"type": "number"}},
            "required": ["customer_id", "amount"],
        },
        executor=lambda customer_id, amount: {"invoice_id": "INV-001", "amount": amount},
    )
)
# ...register 5, 50, or 5,000 more capabilities the same way...

mcp = build_server(registry, name="my-server")
mcp.run()

Whether registry holds 1 capability or 5,000, the MCP client always sees the same 3 tools.

Why this, specifically

  • The registry has no MCP dependency. mcp_lens.registry is plain Python — testable, reusable, and swappable behind any transport. The FastMCP adapter in mcp_lens.server is a thin, optional layer on top.

  • Search is pluggable. The default matcher is keyword substring matching, fine for demos. Pass your own search_fn to CapabilityRegistry for Postgres full-text, embeddings, or whatever search backend you already run — the 3-tool contract doesn't change.

  • It's a spec, not just a library. SPEC.md defines the contract (tool names, schemas, semantics) independently of this implementation, so it can be implemented in other languages and still interoperate conceptually.

  • Validated with real traffic, not just a thought experiment — this pattern (search → schema → execute) has been running in production MCP servers before this repository existed; this is the extracted, product-agnostic version of that mechanism.

Related MCP server: Search MCP Server

Installation

Add mcp-lens to a new or existing Python project with uv:

uv add mcp-lens-py

Or with pip:

pip install mcp-lens-py

Installing from source — track main:

uv add "mcp-lens-py @ git+https://github.com/helygp/mcp-lens.git@main"

Quick Start

1. Define your capabilities

A Capability is a key, a description, a JSON Schema for its input, and a callable (sync or async) that runs it:

from mcp_lens import Capability

def get_weather(city: str) -> str:
    return f"Sunny in {city}"

weather = Capability(
    key="weather.get_weather",
    description="Get current weather for a city",
    input_schema={
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"],
    },
    executor=get_weather,
    tags=("weather", "forecast"),
)

2. Register them

from mcp_lens import CapabilityRegistry

registry = CapabilityRegistry()
registry.register(weather)
# or: registry.register_many([weather, other_capability, ...])

3. Serve them

from mcp_lens import build_server

mcp = build_server(registry, name="my-server")

if __name__ == "__main__":
    mcp.run()

Run the checked-in example instead of writing your own from scratch:

uv run examples/basic/server.py

See examples/README.md for the full walkthrough, including the token-cost comparison in examples/benchmark/.

Learn more

  • SPEC.md — the formal contract: tool names, schemas, semantics, and what's deliberately left out of scope (auth, persistence, discovery UI — those are yours to build).

  • examples/ — a runnable 5-capability example server and a before/after token-cost comparison as the catalog grows.

  • CONTRIBUTING.md — how to propose changes, including changes to the spec itself.

This pattern isn't new — Twenty CRM uses a similar fixed-meta-tool approach for its MCP server, and "don't load every tool definition up front" is an increasingly common idea across the MCP ecosystem as catalogs grow. What mcp-lens adds is not the idea itself but: a formal, implementation-agnostic contract for it (SPEC.md), a tested reference implementation with the MCP-specific parts cleanly separated from the reusable core, and measured numbers for the tradeoff instead of just the claim. If you know of other implementations of this pattern, a PR adding them here is welcome.

Non-goals

mcp-lens is deliberately narrow. It does not provide: authentication, capability persistence/storage, an approval or review UI, or AI-assisted onboarding of new capabilities. Those are real, useful things to build on top of this — but they're product decisions, not part of the protocol pattern this repo exists to document and implement.

Contributing

git clone https://github.com/helygp/mcp-lens.git
cd mcp-lens
uv sync --group dev
uv run pytest
uv run ruff check

See CONTRIBUTING.md for the full workflow.

Citation

If mcp-lens or the pattern in SPEC.md is useful in your work, you can cite the repository:

@software{mcp_lens,
  title  = {mcp-lens: Progressive disclosure for large MCP tool catalogs},
  author = {Pasqual, Hely},
  year   = {2026},
  url    = {https://github.com/helygp/mcp-lens}
}

License

Apache 2.0. See LICENSE.

Available Tools

3 tools
execute_capabilityA

Execute a capability by key, with input matching its schema.

ParametersJSON Schema
NameRequiredDescriptionDefault
keyYes
inputNo

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

There are no annotations provided, so the description must carry the full burden of behavioral disclosure. 'Execute' implies an action that may have side effects, but the description does not mention what the execution does, whether it returns a result, requires authentication, or is irreversible. It provides no behavioral context beyond the action itself.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence of 12 words. It starts with the verb 'Execute' and immediately conveys the primary purpose. There is no waste, redundant phrasing, or irrelevant detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and a generic execution operation, the description is too sparse. It does not explain the execution behavior, what a successful execution looks like, potential errors, or how this fits into the workflow with sibling tools (e.g., obtaining the schema first). It is minimally sufficient for a basic understanding but lacks critical context for safe and correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With a schema description coverage of 0%, the description compensates by explaining the roles of the parameters: 'key' identifies the capability and 'input' must match the capability's schema. This adds meaningful constraint beyond the raw schema types, particularly the requirement that the input object conforms to a specific schema. It does not elaborate on the input structure, but the key relationship is clearly conveyed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action: 'Execute a capability by key' with the input schema constraint. It uses a specific verb (execute) and resource (capability), and the 'by key' mechanism distinguishes it from sibling tools like search_capabilities (searching) and get_capability_schema (retrieving schemas).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by saying 'with input matching its schema,' suggesting that users may need to obtain the schema first (via get_capability_schema). However, it does not explicitly state when to use this tool versus alternatives, nor any prerequisites or exclusions. Usage guidance is minimal and only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_capability_schemaA

Get the input schema for a capability key returned by search_capabilities().

ParametersJSON Schema
NameRequiredDescriptionDefault
keyYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden of behavioral disclosure. It only states 'Get the input schema', which adds no context about read-only guarantees, error behavior, or return format. The output schema exists but is not described in the text, leaving the tool's behavior under-specified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one concise sentence that is front-loaded with the action and resource. It contains no filler and every word contributes to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter getter tool, the description adequately covers purpose and key source. An output schema exists, which presumably documents the return structure. It lacks details on failure scenarios, but overall the description is complete enough for the tool's low complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It clarifies that 'key' is a capability key returned by search_capabilities(), giving meaningful semantics. However, it does not describe the key's format or provide examples, though for a single string parameter this is somewhat acceptable.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'Get' and names the resource 'input schema for a capability key', clearly distinguishing this from sibling tools search_capabilities (which searches) and execute_capability (which executes). It tells the user exactly what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description states the key is 'returned by search_capabilities()', implying the user should first search and then retrieve the schema for a resulting key. This gives clear context on when to use the tool, though it does not explicitly mention when not to use it or how it relates to execute_capability.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_capabilitiesA

Search the capability catalog by keyword or natural language.

Always call this first. Capability keys are not guessable and are not listed anywhere else — this is the only way to discover them. Returns short summaries; call get_capability_schema() on a result before calling execute_capability().

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that results are short summaries, that this is the only discovery method, and that capability keys are not guessable. It implies a read-only search operation. It does not mention error handling or pagination, but the core behavioral traits are well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences, front-loaded with the primary verb and resource. Every sentence adds essential information: what it does, how to use it, and the follow-up workflow. There is no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (so return values need not be described), the description is complete for a search/discovery tool. It explains the critical usage context, the ordering of calls, and the nature of results, making the tool self-contained enough for an agent to execute correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It implicitly explains the 'query' parameter through 'keyword or natural language', but the 'limit' parameter is not addressed at all. The schema only shows a default of 10, leaving the agent to guess its meaning and effect.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches the capability catalog by keyword or natural language. It distinguishes itself from siblings by indicating it returns short summaries and is the sole discovery mechanism for capability keys, setting up the workflow for get_capability_schema and execute_capability.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is given: 'Always call this first' and explains that capability keys are not guessable and not listed elsewhere, making this the only entry point. It also tells the agent to call get_capability_schema before execute_capability, providing a clear when-to-use and sequence.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a distinct role in a clear pipeline: search to discover, get schema to understand inputs, and execute to run. There is no overlap or ambiguity between the three tools.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern: search_capabilities, get_capability_schema, execute_capability. The naming clearly communicates the action and target for each tool.

Tool Count5/5

Three tools is perfectly scoped for a capability catalog interface. Each tool is necessary for the workflow, and there are no redundant or extraneous tools.

Completeness5/5

The tool set covers the full intended workflow: discovering capabilities, understanding their schemas, and executing them. There are no obvious gaps in the core purpose of the server.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    A meta-MCP server that manages and aggregates other MCP servers, enabling LLMs to dynamically extend their own capabilities by searching for, adding, and configuring tool servers.
    16
    142
    AGPL 3.0
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A lightweight and fast MCP server that enables AI agents to efficiently discover and execute tools through progressive disclosure, minimizing context consumption while supporting safe code execution in external environments.
    12
  • A
    license
    Not graded
    quality
    A
    maintenance
    A progressive-disclosure gateway for MCP servers that keeps tool lists small by exposing one top-level tool per server, allowing agents to search, list, inspect, and call underlying tools within a selected domain.
    14
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A meta-MCP server that discovers and explores other MCP servers using progressive disclosure patterns to reduce token usage by up to 99%.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/helygp/mcp-lens'

If you have feedback or need assistance with the MCP directory API, please join our Discord server