Skip to main content
Glama
YamadaYoukai

Code Search MCP

by YamadaYoukai

get_file_context

Retrieve source code context around a matched line, marking the target with '>' to determine if it is a definition, call, or configuration.

Instructions

读取一次代码搜索命中位置周围带行号的源码上下文。

应在 search_code 返回候选命中后调用,并原样传入该命中的 repo、path 和 line。适合确认命中属于定义、调用还是配置,以及在回答用户前理解附近 的控制流。返回内容以 > 标出目标行,并包含实际起止行、文件总行数 和是否截断。不要用它搜索未知文件,也不要传入绝对路径或 .. 路径。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYessearch_code 命中结果中的 path 字段;必须是仓库内相对路径
repositoryYessearch_code 命中结果中的 repo 字段(仓库名称)
line_numberYessearch_code 命中结果中的 line 字段(从 1 开始)
lines_afterNo目标行之后返回的源码行数,默认 20
lines_beforeNo目标行之前返回的源码行数,默认 20

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
end_lineYes
file_pathYes
truncatedNo
repositoryYes
start_lineYes
target_lineYes
total_linesYes
Behavior4/5

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

No annotations provided, so the description carries the full burden. It discloses output format (target line marked with >, start/end lines, total lines, truncation flag) and constraints (relative paths only). It does not mention error handling or side effects, but the read-only nature is implied. Transparency is good but not exhaustive.

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 concise and front-loaded with purpose. Every sentence adds value: purpose, usage context, what not to do, output format. No redundant or verbose language. Efficiently structured.

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?

Given the tool has 5 parameters with 100% schema coverage, an output schema, and no annotations, the description covers the essential aspects: when to use, parameter source, prohibitions, and output details. It could mention error behavior, but overall it is sufficiently complete for effective tool invocation.

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?

Schema coverage is 100%, so baseline is 3. The description adds value by clarifying that parameters should come from search_code hits (file_path is relative, repository is repo name, line_number is from hit's line field) and provides defaults/max for lines_after/before. This connects the schema to the usage context.

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 reads source context with line numbers around a code search hit. It uses a specific verb and resource, and distinguishes itself from sibling tool search_code by indicating it should be called after search_code returns hits.

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?

The description explicitly states when to use ('after search_code returns candidate hits'), provides context for what it is suitable for (confirming hit type, understanding control flow), and gives prohibitions (don't search unknown files, don't use absolute paths). This provides complete guidance.

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

Install Server

Other Tools

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/YamadaYoukai/CodeNavigator'

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