fix: Sanitize graph props and strip /workspace/ paths for remote MCP use#656
Open
bchrao wants to merge 4 commits intoCodeGraphContext:mainfrom
Open
fix: Sanitize graph props and strip /workspace/ paths for remote MCP use#656bchrao wants to merge 4 commits intoCodeGraphContext:mainfrom
bchrao wants to merge 4 commits intoCodeGraphContext:mainfrom
Conversation
|
@bchrao is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
4d729b5 to
b32a783
Compare
Two fixes for running CGC as a remote MCP server in Kubernetes: 1. Strip /workspace/ prefix from all path values in tool results (server.py call_tool handler) so LLMs see repo-relative paths like `myrepo/src/app.py` instead of container-absolute paths. Handles both direct path keys and Cypher-aliased keys (e.g. f.path). 2. Sanitize non-primitive property values before storing in FalkorDB (graph_builder.py). Parser-produced tuples (context in call nodes across all language parsers) and lists-of-dicts (detailed_args in C parser) are serialized to JSON strings. Fixes "Property values can only be of primitive types" error that caused C/C++ repo indexing to fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b32a783 to
9d51b94
Compare
Contributor
Author
|
The E2E test failure is unrelated to this PR's changes. The error is: This occurs during The E2E workflow passes on |
The **params spread passes tuples (e.g. context) from language parsers directly to Cypher, which FalkorDB rejects. Wrap with _sanitize_props(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rewrite sanitizer to whitelist primitives instead of blacklisting known bad types, catching all non-primitive values - Sanitize call_params dicts passed to _safe_run_create for CALLS edges Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The _sanitize_props helper was serializing rel_props (a dict) to a JSON string, but FalkorDB's SET r += $rel_props requires a map parameter. Exclude rel_props from sanitization and pass it as a raw dict. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Strip
/workspace/prefix from tool result paths — When CGC runs as a remote MCP server (via mcp-proxy SSE in K8s),index_repositoryclones repos into/workspace/<repo>inside the container. All tool results now automatically strip this prefix so LLMs see repo-relative paths (e.g.myrepo/src/app.py). Handles both direct path keys and Cypher-aliased keys likef.path.Sanitize non-primitive FalkorDB properties — Language parsers produce tuples (
contextin call nodes) and lists-of-dicts (detailed_argsin C functions) which FalkorDB rejects. These are now serialized to JSON strings beforeSET n += $props. Fixes "Property values can only be of primitive types" error that caused C/C++ repo indexing to fail after a few files.Update LLM system prompt for remote architecture — Rewrite the
prompts.pysystem prompt to reflect that the MCP server runs as a remote container service, not locally. Add a "Remote Server Architecture" section explaining thatindex_repositoryclones into the server container,add_code_to_graph/watch_directoryoperate on the server's filesystem, and returned paths are relative. Add all 12 previously missing tools to the Tool Manifest table (e.g.index_repository,list_indexed_repositories,delete_repository,find_dead_code,load_bundle,search_registry_bundles,visualize_graph_query, etc.).Files Changed
src/codegraphcontext/server.py— Added_strip_workspace_prefixrecursive helper, applied incall_toolhandlersrc/codegraphcontext/tools/graph_builder.py— Added_sanitize_propshelper, applied beforesession.runsrc/codegraphcontext/prompts.py— Rewrote Role/Goal section for remote architecture, added all missing tools to Tool ManifestTest plan
./tests/run_tests.sh fast— all 32 tests passlist_indexed_repositoriesreturns"path": "gokart-c"(not/workspace/gokart-c)find_codereturns repo-relative pathsexecute_cypher_querywithMATCH (f:File) RETURN f.pathreturns stripped pathsindex_repositoryon a 1620-file C repo indexes with zero errors (previously failed at 3 files)instructionsfield🤖 Generated with Claude Code