Skip to main content
Glama

get_source

Retrieve the exact source body of a C/C++ function or enum using libclang AST extents, eliminating line number guessing.

Instructions

USE INSTEAD OF generic file readers (ctx_read, cat, read). Read a C/C++ function/method/enum body using libclang exact extents — no guessing line numbers. No LLM, fast.

Generic readers don't know where a function actually ends — libclang tracks exact {start, end} from the AST. For enums, includes a constants array listing all member constants with their values.

For rich context (who calls this, what does it call) use get_symbol_context instead. For the full file, use a normal file read.

Returns: dict: {name, qualified_name, kind, file, line, signature, is_definition, is_template, is_virtual, is_pure_virtual, source (str — the function/enum body, truncated at 8000 chars), warning (str, optional — when source file cannot be read)}. May also include template_usr, parent_usr, enum_value, constants (list for enums) when applicable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesFully qualified symbol name. Returns exact function body via libclang extent.
project_rootNoProject root. Auto-detected if omitted.
Behavior5/5

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

Despite no annotations, the description fully discloses behavior: uses libclang exact extents, no LLM, fast, truncation at 8000 chars, optional warning, and return fields. It also states what it doesn't do.

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 well-structured with a bold header, explanatory sentences, usage guidance, and a clear return list. It is concise yet comprehensive, with no wasted words.

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 tool's complexity and lack of output schema, the description covers all necessary behavioral and return details, including truncation, warning, and field descriptions, making it fully informative.

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 context by explaining that 'name' is a fully qualified symbol name and that 'project_root' is auto-detected, adding value beyond the schema.

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 it reads C/C++ function/method/enum bodies using libclang exact extents, distinguishing from generic file readers. The verb 'Read' and specific resource are well-defined.

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?

Explicitly says 'USE INSTEAD OF generic file readers' and provides alternatives: 'For rich context use get_symbol_context' and 'for full file use normal read'. This clearly guides when to use the tool.

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/turbyho/fw-context-mcp'

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