grafema-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| GRAFEMA_RFDB_SERVER | No | Path to RFDB server binary (auto-detected). Use when developing Grafema or using custom builds. | |
| GRAFEMA_ORCHESTRATOR | No | Path to orchestrator binary (auto-detected). Use when developing Grafema or using custom builds. |
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {} |
| prompts | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| query_graphA | Execute a Datalog or Cypher query on the code graph. Set language to "cypher" for Cypher queries (e.g., MATCH (n:FUNCTION) RETURN n.name). Default is Datalog. Available Datalog predicates:
NODE TYPES:
EDGE TYPES:
EXAMPLES: violation(X) :- node(X, "MODULE"). violation(X) :- node(X, "FUNCTION"), attr(X, "file", "src/api.js"). violation(X) :- node(X, "CALL"), + edge(X, _, "CALLS"). violation(F, Ms) :- node(M, "METRIC"), attr(M, "name", "parse_ms"), attr(M, "value", Ms), gte(Ms, 500), edge(M, Mod, "OBSERVES"), attr(Mod, "file", F). |
| find_callsA | Find every place in the codebase that calls a specific function or method. Use this when you need to answer:
Returns file, line, and whether the call target is resolved (linked to its definition in the graph). |
| find_nodesA | Find nodes in the graph by type, name, or file pattern. Use this when you need to:
Returns semantic IDs that you can pass to get_context, get_node, get_neighbors, or find_guards. Supports partial matches on name and file. When a name filter returns no exact matches, automatically falls back to fuzzy name matching using token similarity (CamelCase/snake_case aware). Use limit/offset for pagination. |
| trace_aliasA | Trace an alias chain to find the original source. For code like: const alias = obj.method; alias(); This traces "alias" back to "obj.method". |
| trace_dataflowA | Trace data flow paths from or to a variable/expression. Use this when you need to:
Direction options:
Use cases:
Returns: List of nodes in the data flow chain with edge types and depth. Tip: Start with max_depth=5, increase if needed. |
| trace_callsA | Trace call chains from or to a function/method, following CALLS and CALLS_REMOTE edges transitively. Use this when you need to:
Unlike trace_dataflow (which follows data assignments), this follows function CALLS edges:
Returns: Indented call tree showing each hop with file:line location. |
| trace_effectsA | Trace transitive side effects of a function through its call graph. For any function, traverses CALLS edges (DFS) and collects effects from leaf nodes using the effects-db (Node.js builtins, npm packages). Use this when you need to:
Effect types: PURE, MUTATION, IO (with subtypes like IO:FILE:READ, IO:HTTP:REQUEST), THROW, ASYNC, NONDETERMINISTIC, UNKNOWN. UNKNOWN means: unresolved call, external package not in effects-db, or depth limit reached. Returns: direct effects, transitive effects, boundary crossings, leaf sources. |
| get_shapeA | Get the shape (methods + properties) of a CLASS, INTERFACE, or typed variable. Shows all members including inherited ones via EXTENDS chain. For variables, follows INSTANCE_OF to find the type, then returns its shape. Use this to understand:
Returns: members (methods + properties), extends chain, implements list. |
| explainA | Explain a code element using graph data — returns structured context + prompt for the LLM to summarize. Unlike other tools that return raw data, this tool returns graph query results PLUS a natural-language prompt asking the calling LLM to explain the results to the user. The LLM uses its own reasoning to produce a human-readable summary. No extra API calls needed — the calling model (Claude, GPT, etc.) does the summarization. Use cases:
The question parameter guides what graph data to fetch and how to frame the summary. |
| explain_factA | Explain WHY a derived (Datalog) fact holds — returns the rule that derived it plus the supporting body facts (why()/provenance). This is the inverse of "what holds": instead of listing results, it justifies ONE result. Provenance is computed on demand against the current graph snapshot. Default program is the bundled depends.dl, so the common use is explaining a MODULE→MODULE dependency edge:
For a custom rule, pass its source. |
| sim_datalogA | Predict which NEW derived facts a hypothetical change would create — WITHOUT committing anything (what-if simulation). Give it hypothetical nodes and/or edges; it evaluates the program over base ∪ overlay and returns only the facts that are NEW vs the current graph (sim ∖ base). Default program is the bundled depends.dl, so the common use is previewing module dependencies:
Hypothetical node ids may be NEW (invent a decimal id) — an edge may reference them, so you can simulate a wholly new module/import, not only bridge existing nodes. The committed graph is never touched. Companion to explain_gap: gap names the missing premise, sim verifies that adding it produces the fact. |
| explain_gapA | Explain why a derived (Datalog) fact does NOT hold — the why-not dual of explain_fact. Returns the rule whose gap it characterizes, the body premises that WERE satisfiable (with the head bound), and the first premise no binding satisfies:
Default program is the bundled depends.dl, so the common use is explaining a missing MODULE→MODULE dependency:
A "no gap" result means the fact actually IS derivable (use explain_fact), or no rule head matches the key. |
| check_invariantA | Check a one-off code invariant using a Datalog rule. Returns violations if broken. Use this for ad-hoc checks without saving a permanent guarantee. For persistent rules, use create_guarantee + check_guarantees instead. Use cases:
Returns: List of nodes violating the rule, with file and line info. |
| find_shared_behaviorsA | List clusters of FEATUREs whose entry-points share an identical BEHAVIOR (same forward-slice hash). Surfaces cross-modality duplication — e.g. "this CLI command is a thin wrapper around the same library function as that HTTP endpoint" or "this MCP tool and that VS Code command delegate to identical logic". Each cluster contains:
Cluster types are FEATURE node types: cli:command, mcp:tool, vscode:command (and any future domain types created by enrichers). Returns clusters ordered by size (largest first), then hash (deterministic tie-break). Empty result means every FEATURE has a unique implementation. |
| discover_servicesA | Discover services in the project without running full analysis. Use this during onboarding to understand project structure BEFORE running analyze_project. Returns:
Workflow:
Tip: If project has no .grafema/config.yaml, this scans for common patterns (package.json, index.ts, etc.). Use write_config to save the configuration. |
| analyze_projectA | Build the code graph by analyzing project source code. REQUIRED before using query tools. Without analysis, the graph is empty. Options:
Phases: Discovery → Indexing → Analysis → Enrichment → Validation Returns: Analysis summary with node/edge counts and timing. Tip: Use get_stats after analysis to verify graph was built successfully. |
| get_analysis_statusA | Get the current analysis status and progress. Use this to:
Returns: { running: boolean, phase: string, progress: number, error: string | null } Call this periodically after analyze_project to monitor progress. |
| get_statsA | Get graph statistics: node and edge counts by type. Use this to:
Returns:
Use BEFORE querying an unfamiliar graph to understand what data is available. |
| get_schemaA | Get the graph schema: available node and edge types with counts. Use this to:
Options:
Tip: Run this first when exploring a new graph to learn the available vocabulary. |
| create_guaranteeB | Create a new code guarantee. Two types supported:
Examples:
|
| list_guaranteesA | List all defined code guarantees (rules and contracts). Use this to:
Returns for each guarantee: name, type, description, rule/schema, priority, status. Use BEFORE check_guarantees to see what will be validated. |
| check_guaranteesA | Validate code against defined guarantees and return violations. Use this to:
Returns: Violations array with node IDs, file, line, rule name. Empty array = all guarantees pass. |
| delete_guaranteeA | Delete a guarantee by name. Use this when:
This permanently removes the guarantee. Use list_guarantees first to verify the name. |
| get_function_detailsA | Get comprehensive details about a function, including what it calls and who calls it. Graph structure: FUNCTION -[HAS_SCOPE]-> SCOPE -[CONTAINS]-> CALL/METHOD_CALL CALL -[CALLS]-> FUNCTION (target) Returns:
For calls array:
Use transitive=true to follow call chains (A calls B calls C). Max transitive depth is 5 to prevent explosion. |
| get_contextA | Get deep context for a graph node: source code + full graph neighborhood. Shows ALL incoming and outgoing edges grouped by type, with source code at each connected node's location. Works for ANY node type. Use this after find_nodes or query_graph to deep-dive into a specific node. Output includes:
Primary edges (CALLS, ASSIGNED_FROM, DEPENDS_ON, etc.) include code context. Structural edges (CONTAINS, HAS_SCOPE, etc.) are shown in compact form. |
| get_file_overviewA | Understand what a file does without reading it — shows structure and relationships from the graph. USE THIS FIRST when you need to understand a file. It replaces reading the file with a structured summary: imports, exports, classes, functions, variables, and how they connect to the rest of the codebase. Returns:
After this, use get_context with specific node IDs to deep-dive into relationships. |
| find_guardsA | Find conditional guards protecting a node. Returns all SCOPE nodes that guard the given node, walking from inner to outer scope. Useful for answering "what conditions must be true for this code to execute?" Each guard includes:
Example use cases:
|
| read_project_structureA | Get the directory structure of the project. Returns a tree of files and directories, useful for understanding project layout during onboarding. Excludes: node_modules, .git, dist, build, .grafema, coverage, .next, .nuxt Use this tool when studying a new project to identify services, packages, and entry points. |
| write_configA | Write or update the Grafema configuration file (.grafema/config.yaml). Validates all inputs before writing. Creates .grafema/ directory if needed. Use this tool after studying the project to save the discovered configuration. Only include fields you want to override — defaults are used for omitted fields. |
| get_coverageA | Check which files were analyzed and which were skipped. Use this to:
Returns: analyzed/skipped file counts, coverage percentage, skip reasons. Use AFTER analyze_project when queries return unexpected empty results. |
| get_documentationA | Get documentation about Grafema usage and query syntax. Topics available:
Use this when you need to learn Datalog syntax, DSL notation, or understand available features. |
| report_issueA | Report a bug or issue with Grafema to GitHub. Use this tool when you encounter:
The tool will create a GitHub issue automatically if GITHUB_TOKEN is configured. If not configured, it will return a pre-formatted issue template that the user can manually submit at https://github.com/Disentinel/grafema/issues/new IMPORTANT: Always ask the user for permission before reporting an issue. Include relevant context: error messages, file paths, query used, etc. |
| get_nodeA | Get a single node by its semantic ID with full metadata. Use this when you have a node ID from find_nodes, query_graph, or another tool and need the complete record. Returns: All node properties (type, name, file, line, exported) plus type-specific metadata (async, params, className, etc.). Use cases:
Tip: For relationships and code context, use get_context instead. For just the direct edges, use get_neighbors. |
| get_neighborsA | Get direct neighbors of a node — all incoming and/or outgoing edges. Returns edges grouped by type with connected node summaries. Use this when you need:
Direction options:
Edge type filter: Pass edgeTypes to see only specific relationships. Omit to get all edge types. Cheaper than get_context (no code snippets). Use when you only need the graph structure, not source code. |
| traverse_graphA | Traverse the graph using BFS from start nodes, following specific edge types. Use this for:
Returns nodes with depth info (0 = start, 1 = direct neighbor, 2+ = transitive). Direction:
Examples:
Tip: Start with maxDepth=5. Use get_schema(type="edges") to find valid edge type names. |
| rememberA | Quick knowledge write — store a fact about a subject. Use this when you:
The subject becomes a node (or reuses an existing one), and the fact is stored as an assertion from that node. Example: remember(subject="RFDB compaction", fact="flush_data_only was a no-op in V2 engine", domain="engineering") |
| recallA | Broad "what do we know about X" — combines embedding search with graph traversal. Use this at session start or before making decisions to check for prior art, known failures, and existing context. Depth controls how far to traverse from matched nodes:
Example: recall(query="federation architecture", depth=2) |
| semantic_searchA | Substring search across knowledge-graph node names (case-insensitive). NOTE: despite the name, embedding-based semantic ranking is not wired yet (RFD-63). This currently matches substrings of node names — results are plain matches, not similarity-ranked. Use recall for broader retrieval. Example: semantic_search(query="auth token", top_k=5, domain="devops") |
| enox_exploreA | Get all edges around an entity in the knowledge graph — see everything connected to it. Use this to understand the full context of an entity: what it relates to, what depends on it, what contradicts it, etc. Returns all incoming and outgoing edges with connected node summaries. Example: explore(entity="RFDB V2 engine") |
| add_assertionA | Create a precise edge between two nodes in the knowledge graph. Use this when you need exact control over the graph structure:
Both "from" and "to" become nodes if they don't exist yet. Example: add_assertion(from="Grafema", relation="uses", to="RFDB", context="RFDB is the storage engine for code graphs", confidence=1.0) |
| update_assertionA | Update an existing edge in the knowledge graph. Use this to change the context or confidence of a previously recorded assertion without deleting and re-creating it. Example: update_assertion(fact_id="edge-abc123", confidence=0.5, context="Partially confirmed after testing") |
| delete_assertionA | Remove an edge from the knowledge graph. Use this when an assertion is wrong, outdated, or no longer relevant. Consider using update_assertion to lower confidence instead of deleting, or add_assertion with "supersedes" relation to record the replacement. Example: delete_assertion(fact_id="edge-abc123") |
| enox_queryA | Filter nodes in the knowledge graph by type, domain, or name. Use this for exact filtering when you know what you're looking for. Unlike semantic_search, this does exact/substring matching on fields. Example: query_graph(type="decision", domain="engineering", limit=20) |
| enox_traverseA | Graph traversal from a knowledge entity following specific edge types and direction. Use this for structured exploration:
Returns nodes with depth info (0 = start, 1 = direct, 2+ = transitive). Example: traverse(start="RFDB", direction="outgoing", edge_types=["depends_on", "uses"], max_depth=3) |
| enox_statsA | Get statistics about the Enox knowledge graph. Use this to:
Returns: total nodes, total edges, counts by type, domain distribution. |
| recent_activityA | Get recently created or updated nodes and edges. Use this at session start to see what other sessions have recorded recently. Helps avoid duplicating work and provides continuity across sessions. Example: recent_activity(since="2026-05-20T00:00:00Z", limit=10) |
| update_nodeA | Update metadata on an existing node in the knowledge graph. Use this to rename, re-domain, or add descriptions to existing nodes without affecting their edges. Example: update_node(node_id="node-abc123", description="V2 storage engine with segment-based persistence") |
| crawl_entityA | Run ontological crawl on a code entity — generate hypotheses and verify against code graph. Uses the Grafema code graph for verification. Records findings in knowledge database. Example: crawl_entity(entity="compactionEnricher", context="TypeScript enricher creating FEATURE nodes") |
| save_documentA | Store a document or artifact as a node in the knowledge graph. Use this for longer-form content that should be persisted:
The document becomes a node with its content stored. Use relates_to to link it to relevant entities in the graph. Example: save_document(title="ADR: Federation via thick client", content="## Context\n...", doc_type="adr", relates_to=["Grafema", "RFDB"]) |
| describeA | Render a node's neighborhood as compact Grafema DSL notation. Reduces verbose edge listings to archetype-grouped visual operators: o- dependency/import
Containment edges ({ }) define nesting structure. Example output: login { o- imports bcrypt > calls UserDB.findByEmail, createToken < reads config.auth => writes session >x throws AuthError ~>> emits 'auth:login' } Use depth to control detail: 0 = names only (children listed, no edges) 1 = edges (default — shows all relationship lines) 2 = nested + folded (compressed view — repetitive siblings collapsed) 3 = nested (exact — every node expanded, no folding) 10-30 lines vs 500+ lines of raw edge data. Ideal for LLM context windows. |
| query_graphqlA | Execute a GraphQL query on the code graph. GraphQL provides typed, nested queries with pagination — complementary to Datalog. Use GraphQL when you need nested data in one query (node + edges + neighbors). Use Datalog (query_graph) for pattern matching and logical rules. SCHEMA HIGHLIGHTS:
Node fields: id, name, type, file, line, column, exported, metadata, outgoingEdges(types), incomingEdges(types), children, parent EXAMPLE: query { nodes(filter: {type: "FUNCTION", file: "src/api"}, first: 5) { edges { node { name, file, line outgoingEdges(types: ["CALLS"]) { edges { node { dst { name, file } } } } } } totalCount } } Use get_documentation(topic="graphql-schema") for the full schema. |
| query_registryA | Query the local manifest registry for package export information and side effects. The registry contains pre-analyzed manifests for npm dependencies. Each manifest describes a package's API surface: exported symbols, their kinds, and side effects. Use this when you need to:
Returns: package metadata (purl, source_type, confidence), and either:
source_type values:
|
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| onboard_project | Step-by-step instructions for studying a new project and configuring Grafema for analysis. Use this when setting up Grafema for the first time on a project. |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
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/Disentinel/grafema'
If you have feedback or need assistance with the MCP directory API, please join our Discord server