Skip to main content
Glama
token-context-mcp

token-context-mcp

Search source

search_source
Read-onlyIdempotent

Search code bodies with FTS5 keywords or identifiers to return token-budgeted line snippets; use it to locate relevant source lines without crawling entire repositories.

Instructions

Full-text FTS5 body search returning line snippets (omitted_count on budget cap). For symbol name patterns use find_symbols; for multi-hop call graphs use get_impact_slice.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "repo_id": "<repo_id>",
      "query": "<query>"
    },
    "name": "search_source"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum symbol hits to return before token packing (1 to 100; defaults to 'locate' profile limit).
queryYesSpace-separated FTS5 keywords or code identifiers (runs AND query first, topped up with OR if sparse).
expandNoNeighbor expansion: 'auto' (graph under 'locate' profile, none otherwise), 'none', or 'graph' (adds top-k callers/callees).auto
profileNoBudget profile ('locate', 'orient', 'impact', 'read'); 'locate' defaults expand='graph', others default expand='none'.
repo_idYesRegistered repository ID from list_repositories (never a filesystem path).
expand_kNoNumber of top search hits used as seeds for graph neighbor expansion (1 to 8).
max_tokensNoToken cap for hits plus expanded neighbors (32 to max_result_tokens; defaults to 'locate' profile budget).
expand_hopsNoCall-graph traversal hops from each expanded seed hit (1 or 2).
min_confidenceNoMinimum AST/lexical edge confidence (0.0 to 1.0) required to include an expanded neighbor.

Output Schema

NameRequiredDescriptionDefault
dataNoRanked source hits and optional 1-2 hop graph neighbors.
errorNoPresent when the tool call fails (either a structured {code, message, details} object or a diagnostic string).
budgetNoToken budget accounting for this response.
repo_idNoRegistered repository identifier.
evidenceNoSource-verified file line spans and SHA-256 hashes backing the response.
warningsNoFreshness, ambiguity, redaction, or security warnings.
freshnessNoIndex freshness state ('fresh', 'pending', 'stale', or 'unknown').
truncatedNoTrue if items were omitted due to budget or node limits.
ledger_revNoCurrent evidence ledger revision for repo_id.
completenessNoCoverage/resolution completeness indicator.
index_run_idNoIdentifier of the active index snapshot run.
schema_versionNoEnvelope schema version ('1.0').
untrusted_repository_contentNoTrue when payload embeds raw repository text.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changedv0.3.8
    • changedInput schema / properties / expand / description
      Previous value: -"Neighbor expansion mode: 'auto' (graph for locate profile), 'none', or 'graph' (add callers/callees)."New value: +"Neighbor expansion: 'auto' (graph under 'locate' profile, none otherwise), 'none', or 'graph' (adds top-k callers/callees)."
    • changedInput schema / properties / expand_hops / description
      Previous value: -"Graph traversal hops for neighbor expansion (1 or 2)."New value: +"Call-graph traversal hops from each expanded seed hit (1 or 2)."
    • changedInput schema / properties / expand_k / description
      Previous value: -"Number of top search hits to expand with graph neighbors (1 to 8)."New value: +"Number of top search hits used as seeds for graph neighbor expansion (1 to 8)."
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of search hits to return (1 to 100)."New value: +"Maximum symbol hits to return before token packing (1 to 100; defaults to 'locate' profile limit)."
    • changedInput schema / properties / max_tokens / description
      Previous value: -"Maximum token budget for the response (32 to max_result_tokens)."New value: +"Token cap for hits plus expanded neighbors (32 to max_result_tokens; defaults to 'locate' profile budget)."
    • changedInput schema / properties / min_confidence / description
      Previous value: -"Minimum edge confidence threshold (0.0 to 1.0) for expanded graph neighbors."New value: +"Minimum AST/lexical edge confidence (0.0 to 1.0) required to include an expanded neighbor."
    • changedInput schema / properties / profile / description
      Previous value: -"Named budget profile ('locate', 'orient', 'impact', 'read'); defaults to 'locate'."New value: +"Budget profile ('locate', 'orient', 'impact', 'read'); 'locate' defaults expand='graph', others default expand='none'."
    • changedInput schema / properties / query / description
      Previous value: -"Full-text FTS5 search keywords or code tokens to match across indexed symbols."New value: +"Space-separated FTS5 keywords or code identifiers (runs AND query first, topped up with OR if sparse)."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "properties": {
      +    "budget": {
      +      "additionalProperties": true,
      +      "description": "Token budget accounting for this response.",
      +      "properties": {
      +        "envelope_reserve": {
      +          "description": "Wire-framing token reserve when budget >= 512.",
      +          "type": "integer"
      +        },
      +        "estimated_tokens": {
      +          "description": "Estimated serialized response tokens.",
      +          "type": "integer"
      +        },
      +        "requested_tokens": {
      +          "description": "Requested or profile-default token budget.",
      +          "type": "integer"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "completeness": {
      +      "additionalProperties": true,
      +      "description": "Coverage/resolution completeness indicator.",
      +      "properties": {
      +        "basis": {
      +          "description": "How completeness was computed.",
      +          "type": "string"
      +        },
      +        "value": {
      +          "description": "Completeness ratio in [0.0, 1.0], or null if N/A.",
      +          "type": [
      +            "number",
      +            "null"
      +          ]
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "data": {
      +      "additionalProperties": true,
      +      "description": "Ranked source hits and optional 1-2 hop graph neighbors.",
      +      "properties": {
      +        "estimator_version": {
      +          "description": "Token estimator version.",
      +          "type": "string"
      +        },
      +        "matches": {
      +          "description": "Matched symbol snippets ordered by FTS5 relevance.",
      +          "items": {
      +            "additionalProperties": true,
      +            "properties": {
      +              "end_line": {
      +                "description": "1-based end line of the match.",
      +                "type": "integer"
      +              },
      +              "lines": {
      +                "description": "Pairs of [line_number, text].",
      +                "items": {
      +                  "type": "array"
      +                },
      +                "type": "array"
      +              },
      +              "path": {
      +                "description": "Repository-relative file path.",
      +                "type": "string"
      +              },
      +              "redacted_lines": {
      +                "description": "Number of redacted lines if secrets were masked.",
      +                "type": "integer"
      +              },
      +              "snippet": {
      +                "description": "Matched source line (secret-redacted).",
      +                "type": "string"
      +              },
      +              "start_line": {
      +                "description": "1-based line number of the match.",
      +                "type": "integer"
      +              },
      +              "symbol_id": {
      +                "description": "Enclosing symbol ID, or null for module-level hits.",
      +                "type": [
      +                  "string",
      +                  "null"
      +                ]
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "neighbors": {
      +          "description": "Expanded caller/callee neighbor tuples when expand='graph'.",
      +          "items": {
      +            "type": "array"
      +          },
      +          "type": "array"
      +        },
      +        "omitted_count": {
      +          "description": "Number of search matches omitted due to limit or budget.",
      +          "type": "integer"
      +        },
      +        "prior_evidence": {
      +          "additionalProperties": true,
      +          "description": "Matching verified evidence card from the repo ledger when available.",
      +          "properties": {
      +            "card_id": {
      +              "description": "Ledger card identifier.",
      +              "type": "integer"
      +            },
      +            "recheck_from": {
      +              "description": "Stale anchor paths requiring re-verification when VERIFY_FAILED.",
      +              "items": {
      +                "type": "string"
      +              },
      +              "type": "array"
      +            },
      +            "status": {
      +              "description": "Ledger verification status ('confirmed', 'valid', or 'VERIFY_FAILED').",
      +              "type": "string"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "query": {
      +          "description": "Search query string.",
      +          "type": "string"
      +        },
      +        "retrieval": {
      +          "additionalProperties": true,
      +          "description": "Graph expansion diagnostics when expand='graph'.",
      +          "properties": {
      +            "anchors": {
      +              "description": "Number of anchor symbols expanded.",
      +              "type": "integer"
      +            },
      +            "expand_effective": {
      +              "description": "Effective expansion mode used.",
      +              "type": "string"
      +            },
      +            "expand_hops": {
      +              "description": "Graph traversal depth applied.",
      +              "type": "integer"
      +            },
      +            "expand_k": {
      +              "description": "Top-k anchors limit applied.",
      +              "type": "integer"
      +            },
      +            "min_confidence": {
      +              "description": "Minimum edge confidence filter applied.",
      +              "type": "number"
      +            },
      +            "neighbors": {
      +              "description": "Number of neighbor rows returned.",
      +              "type": "integer"
      +            },
      +            "profile_effective": {
      +              "description": "Active budget profile.",
      +              "type": [
      +                "string",
      +                "null"
      +              ]
      +            }
      +          },
      +          "type": "object"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "error": {
      +      "additionalProperties": true,
      +      "description": "Present when the tool call fails (either a structured {code, message, details} object or a diagnostic string).",
      +      "properties": {
      +        "code": {
      +          "description": "Machine-readable error code.",
      +          "type": "string"
      +        },
      +        "details": {
      +          "description": "Optional structured metadata for the error.",
      +          "type": "object"
      +        },
      +        "message": {
      +          "description": "Human-readable error explanation.",
      +          "type": "string"
      +        }
      +      },
      +      "type": [
      +        "object",
      +        "string"
      +      ]
      +    },
      +    "evidence": {
      +      "description": "Source-verified file line spans and SHA-256 hashes backing the response.",
      +      "items": {
      +        "additionalProperties": true,
      +        "properties": {
      +          "end_line": {
      +            "description": "1-based end line in source.",
      +            "type": "integer"
      +          },
      +          "path": {
      +            "description": "Repository-relative file path.",
      +            "type": "string"
      +          },
      +          "sha256": {
      +            "description": "12-character hex prefix of indexed file SHA-256.",
      +            "type": "string"
      +          },
      +          "start_line": {
      +            "description": "1-based start line in source.",
      +            "type": "integer"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "freshness": {
      +      "description": "Index freshness state ('fresh', 'pending', 'stale', or 'unknown').",
      +      "type": "string"
      +    },
      +    "index_run_id": {
      +      "description": "Identifier of the active index snapshot run.",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "ledger_rev": {
      +      "description": "Current evidence ledger revision for repo_id.",
      +      "type": "integer"
      +    },
      +    "repo_id": {
      +      "description": "Registered repository identifier.",
      +      "type": "string"
      +    },
      +    "schema_version": {
      +      "description": "Envelope schema version ('1.0').",
      +      "type": "string"
      +    },
      +    "truncated": {
      +      "description": "True if items were omitted due to budget or node limits.",
      +      "type": "boolean"
      +    },
      +    "untrusted_repository_content": {
      +      "description": "True when payload embeds raw repository text.",
      +      "type": "boolean"
      +    },
      +    "warnings": {
      +      "description": "Freshness, ambiguity, redaction, or security warnings.",
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "type": "object"
      +}
  2. Changed9 schema fields changedv0.3.7
    • addedInput schema / properties / expand / description
      Added value: +"Neighbor expansion mode: 'auto' (graph for locate profile), 'none', or 'graph' (add callers/callees)."
    • addedInput schema / properties / expand_hops / description
      Added value: +"Graph traversal hops for neighbor expansion (1 or 2)."
    • addedInput schema / properties / expand_k / description
      Added value: +"Number of top search hits to expand with graph neighbors (1 to 8)."
    • addedInput schema / properties / limit / description
      Added value: +"Maximum number of search hits to return (1 to 100)."
    • addedInput schema / properties / max_tokens / description
      Added value: +"Maximum token budget for the response (32 to max_result_tokens)."
    • addedInput schema / properties / min_confidence / description
      Added value: +"Minimum edge confidence threshold (0.0 to 1.0) for expanded graph neighbors."
    • addedInput schema / properties / profile / description
      Added value: +"Named budget profile ('locate', 'orient', 'impact', 'read'); defaults to 'locate'."
    • addedInput schema / properties / query / description
      Added value: +"Full-text FTS5 search keywords or code tokens to match across indexed symbols."
    • addedInput schema / properties / repo_id / description
      Added value: +"Registered repository ID from list_repositories (never a filesystem path)."
  3. Changed4 schema fields changedv0.2.0
    • addedInput schema / properties / expand
      Added value: +{
      +  "default": "auto",
      +  "enum": [
      +    "auto",
      +    "none",
      +    "graph"
      +  ],
      +  "title": "Expand",
      +  "type": "string"
      +}
    • addedInput schema / properties / expand_hops
      Added value: +{
      +  "default": 1,
      +  "title": "Expand Hops",
      +  "type": "integer"
      +}
    • addedInput schema / properties / expand_k
      Added value: +{
      +  "default": 3,
      +  "title": "Expand K",
      +  "type": "integer"
      +}
    • addedInput schema / properties / min_confidence
      Added value: +{
      +  "default": 0.6,
      +  "title": "Min Confidence",
      +  "type": "number"
      +}
  4. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already establish that the operation is read-only, idempotent, non-destructive, and closed-world. The description adds useful behavioral detail beyond that: it returns line snippets and can report omitted_count when a budget cap is reached, signaling truncation behavior.

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 two tightly written sentences with the core purpose front-loaded. The parenthetical detail about omitted_count is compact and directly relevant, with no wasteful wording.

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 the rich schema descriptions, output schema, and annotations, the description supplies the key missing high-level context: what kind of search this is, what it returns in broad terms, how budget truncation surfaces, and which sibling tools handle adjacent tasks. Nothing essential for correct tool selection is absent.

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 coverage is 100%, so all nine parameters are already documented in the input schema. The description does not add parameter-specific guidance about profiles, expansion, token budgets, or confidence thresholds beyond what the schema provides, so the baseline 3 is appropriate.

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 states a specific verb and resource: a full-text FTS5 body search returning line snippets. It also distinguishes this tool from find_symbols and get_impact_slice by naming the cases those tools cover.

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?

It explicitly routes symbol-name pattern searches to find_symbols and multi-hop call-graph work to get_impact_slice, which clarifies when not to use this tool. It does not cover every sibling alternative, but the main selection boundaries are clear.

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