Problem
In a monorepo, CodeGraph works best when indexes are created at smaller project or service directories rather than at the repository root.
For example:
repo/
service_a/.codegraph/
service_b/.codegraph/
service_c/.codegraph/
The MCP tools already support projectPath, so an agent can query a specific indexed service:
{
"projectPath": "/path/to/repo/service_a"
}
However, if the MCP server is started from a directory that does not itself contain .codegraph/, the server appears inactive and does not expose any MCP tools. This means the agent cannot call the tools at all, even if every intended query would pass a valid projectPath pointing to an indexed subproject.
Why This Hurts
For large monorepos, indexing the repository root is undesirable:
- the root index can be very large and slow
- broad root-level queries can accidentally expand across unrelated services
- each service may be an independent build/deploy unit
- users may intentionally want service-level indexes only
Today, the workaround is to create a small anchor project with a .codegraph/ index and start MCP with:
codegraph serve --mcp --path /path/to/anchor
Then every real query passes projectPath.
This works, but it is unintuitive and easy to misconfigure.
Expected Behavior
It would be useful to have an option to expose MCP tools even when the MCP server root path has no .codegraph/, as long as queries provide projectPath.
For example:
codegraph serve --mcp --allow-project-path-only
or:
codegraph serve --mcp --expose-tools-without-root-index
Then:
- tool discovery would still expose
explore, node, search, callers, etc.
- calls without
projectPath could return a clear "no index at server root" error
- calls with a valid indexed
projectPath would work normally
Actual Behavior
If the MCP server root path has no .codegraph/, the MCP tools are not exposed, so the agent cannot call codegraph_explore, codegraph_node, etc., even with a valid indexed projectPath.
Suggested Solution
Separate MCP tool exposure from the default root project index.
The server could expose tools in a "projectPath required" mode when no root index exists. Each tool invocation would then validate the provided projectPath and use that project's .codegraph/.
This would better support monorepos and multi-service repositories where indexing the root is intentionally avoided.
Problem
In a monorepo, CodeGraph works best when indexes are created at smaller project or service directories rather than at the repository root.
For example:
The MCP tools already support
projectPath, so an agent can query a specific indexed service:{ "projectPath": "/path/to/repo/service_a" }However, if the MCP server is started from a directory that does not itself contain
.codegraph/, the server appears inactive and does not expose any MCP tools. This means the agent cannot call the tools at all, even if every intended query would pass a validprojectPathpointing to an indexed subproject.Why This Hurts
For large monorepos, indexing the repository root is undesirable:
Today, the workaround is to create a small anchor project with a
.codegraph/index and start MCP with:Then every real query passes
projectPath.This works, but it is unintuitive and easy to misconfigure.
Expected Behavior
It would be useful to have an option to expose MCP tools even when the MCP server root path has no
.codegraph/, as long as queries provideprojectPath.For example:
or:
Then:
explore,node,search,callers, etc.projectPathcould return a clear "no index at server root" errorprojectPathwould work normallyActual Behavior
If the MCP server root path has no
.codegraph/, the MCP tools are not exposed, so the agent cannot callcodegraph_explore,codegraph_node, etc., even with a valid indexedprojectPath.Suggested Solution
Separate MCP tool exposure from the default root project index.
The server could expose tools in a "projectPath required" mode when no root index exists. Each tool invocation would then validate the provided
projectPathand use that project's.codegraph/.This would better support monorepos and multi-service repositories where indexing the root is intentionally avoided.