MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / formatNodeDetails

Method formatNodeDetails

src/mcp/tools.ts:4905–4933  ·  view source on GitHub ↗
(node: Node, code: string | null, outline?: string | null)

Source from the content-addressed store, hash-verified

4903 }
4904
4905 private formatNodeDetails(node: Node, code: string | null, outline?: string | null): string {
4906 const location = node.startLine ? `:${node.startLine}` : '';
4907 const lines: string[] = [
4908 `**${node.name}** (${node.kind})`,
4909 '',
4910 `**Location:** ${node.filePath}${location}`,
4911 ];
4912
4913 if (node.signature) {
4914 lines.push(`**Signature:** \`${node.signature}\``);
4915 }
4916
4917 // Only include docstring if it's short and useful
4918 if (node.docstring && node.docstring.length < 200) {
4919 lines.push('', node.docstring);
4920 }
4921
4922 if (outline) {
4923 lines.push('', outline, '',
4924 `> Structural outline only. Read \`${node.filePath}\` or call codegraph_node on a specific member for its body.`);
4925 } else if (code) {
4926 // Line-numbered (cat -n style, like codegraph_explore and Read) so the
4927 // agent can cite/edit exact lines without re-Reading the file for them.
4928 const numbered = node.startLine ? numberSourceLines(code, node.startLine) : code;
4929 lines.push('', '```' + node.language, numbered, '```');
4930 }
4931
4932 return lines.join('\n');
4933 }
4934
4935 private textResult(text: string): ToolResult {
4936 return {

Callers 1

renderNodeSectionMethod · 0.95

Calls 2

numberSourceLinesFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected