Skip to content

Latest commit

 

History

History
201 lines (154 loc) · 6.24 KB

AGENTS.md

File metadata and controls

201 lines (154 loc) · 6.24 KB

AGENTS.md — configure codetree

You are an agent configuring codetree (a read-only stdio MCP server) for the user's project. Do the configuration yourself: edit the client config, reload the client, verify the tools, and report exactly what you changed. Do not publish the package and do not modify codetree's source.

1. Find the project root

git rev-parse --show-toplevel    # or use the current workspace directory

Use that absolute path as <ROOT> everywhere below. Never set CODETREE_ROOTS to /, C:\, or the user's home directory.

2. Verify Node and the package

node -v                                      # must be >= 20
npx -y @ringko-ai/codetree --version         # 0.6.0 or newer
  • 0.6.0+ exposes outline, read_file, search, grep, exports, imports, usages, resolves pnpm/tsconfig workspace packages, groups imports by module, and reports re-exports as via.
  • 0.5.0 adds usages and runtime imports; 0.4.0 adds exports/imports; 0.2.0 adds grep; 0.1.0 only has the first three.
  • The npm registry may still serve an older release (0.3.0 at the time of writing). When a tool is missing, prefer a local checkout (node <CODETREE_DIR>/dist/main.js, run pnpm build first) or the 0.6.0 tarball until 0.6.0 is published.

Smoke test before touching any config:

npx -y @ringko-ai/codetree --roots "<ROOT>" --print src --depth 1

Run it from the user's project, not from inside the codetree package directory (npx resolves the local package there and may fail to find the bin).

3. Add the MCP server to the user's client

Always back up and merge an existing config; never overwrite unrelated servers.

Claude Desktop / Claude Code

claude_desktop_config.json (or the client's MCP settings):

{
  "mcpServers": {
    "codetree": {
      "command": "npx",
      "args": ["-y", "@ringko-ai/codetree"],
      "env": { "CODETREE_ROOTS": "<ROOT>" }
    }
  }
}

VS Code

.vscode/mcp.json in the workspace:

{
  "servers": {
    "codetree": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@ringko-ai/codetree"],
      "env": { "CODETREE_ROOTS": "<ROOT>" }
    }
  }
}

Visual Studio 2022

.mcp.json in the solution directory, or %USERPROFILE%\.mcp.json:

{
  "servers": {
    "codetree": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@ringko-ai/codetree"],
      "env": { "CODETREE_ROOTS": "<ROOT>" }
    }
  }
}

JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm, ...)

Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add → STDIO, then paste:

{
  "mcpServers": {
    "codetree": {
      "command": "npx",
      "args": ["-y", "@ringko-ai/codetree"],
      "env": { "CODETREE_ROOTS": "<ROOT>" }
    }
  }
}

Hermes

hermes mcp add codetree --command npx --env CODETREE_ROOTS="<ROOT>" \
  --args -y @ringko-ai/codetree

--args must be the last option (it consumes the rest of the command line). Reload with /reload-mcp or start a new session.

LM Studio 0.3.17+

Edit mcp.json (Program → Install → Edit mcp.json) and add the mcpServers entry above, then reload. If the build rejects command/args, use its HTTP mode with a stdio→HTTP bridge instead.

Android Studio

Do not configure it: Android Studio's MCP client supports Streamable HTTP only and explicitly does not support stdio. Use one of the clients above, or put a stdio→HTTP bridge in front of codetree and configure httpUrl.

4. Reload and verify

Restart the client or run its MCP reload action, then check that all seven tools are listed:

outline, read_file, search, grep, exports, imports, usages

Call outline on a small directory to confirm parsing:

{ "name": "outline", "arguments": { "path": "src", "depth": 2 } }

Then confirm the module tools: exports on a file, imports on a file with a dynamic import, and usages for a symbol that is called from another file:

{ "name": "usages", "arguments": { "name": "startServer", "include_calls": true } }

If the client shows fewer than seven tools, the registry still resolved an older release — switch to a local checkout or the 0.6.0 tarball.

5. Report

Tell the user: client and config file changed, <ROOT>, codetree version, and the tool list. Mention that the server is read-only and confined to CODETREE_ROOTS.

Using the tools well

  • outline first: directories expand to depth levels; a file appends its resolved reference tree. Start at depth 1–3.
  • read_file with start_line/end_line from the outline; avoid reading whole large files.
  • search for declarations (name/signature/doc). grep for text, with -i, -w, -C, -l, -c, --include, --exclude.
  • exports answers "what does this file or directory publish?" (kinds filters classes, interfaces, functions, ...; export … from rows are via). imports answers "what does it depend on?", with dynamic: true for runtime imports (import(), require(), Class.forName, dlopen, ...) marked dyn; group: false gives one row per symbol, otherwise rows share a specifier. Workspace packages (@scope/pkg) resolve through pnpm-workspace.yaml/workspaces and package exports/main, plus tsconfig paths; they are no longer labelled (external).
  • usages is the reverse lookup: give a name (or target file) and get call sites, imports and type references across the workspace; include_calls and include_imports widen the result.
  • Everything is bounded (characters, entries, files, 20 s); truncation is reported, never silent.

Troubleshooting

Symptom Fix
Connection closed right after adding (Hermes) --args was not last; re-add with --args as the final option
PATH_OUTSIDE_ROOT CODETREE_ROOTS does not contain the path; fix the root, not the path
missing grammars use npx (grammars ship in the package) or rebuild the checkout (pnpm build)
Android Studio rejects the server stdio is unsupported; use HTTP + bridge
Fewer than seven tools registry serves an older release; use 0.6.0+ or the local build

License

Apache-2.0. The full license text is in LICENSE and ships with the npm package.