Skip to main content
Glama

Graph Cypher

graph_cypher
Read-only

Execute a read-only Cypher query on a memory graph to run custom queries beyond built-in tools. Admin-only for tenant-filtered access.

Instructions

Execute a read-only Cypher query against the memory graph. You generate the Cypher — this tool just runs it. Enforced read-only via Neo4j executeRead(). Use for custom queries not covered by other tools. Admin-only (must be the bootstrap tenant) — non-admin tenants would otherwise be able to bypass tenant filtering by writing raw Cypher.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cypherYesCypher query to execute (read-only)
paramsNoQuery parameters

Implementation Reference

  • The graph_cypher tool handler function. It checks if the current tenant is an admin (via isAdminTenant), then calls client.executeCypher() to run a read-only Cypher query against the Neo4j graph. Returns results with execution time.
    }, async (args) => {
      const tenantId = currentTenant();
      if (!isAdminTenant(tenantId)) {
        return toolError(
          `graph_cypher is admin-only (your tenant: ${tenantId}). Use graph_query, graph_entities, or graph_search instead — those are tenant-scoped.`,
        );
      }
      try {
        const result = await client.executeCypher(args.cypher, args.params ?? {});
        return toolResult({
          cypher: args.cypher,
          ...result,
        });
      } catch (err) {
        return toolError(`graph_cypher failed: ${err instanceof Error ? err.message : String(err)}`);
      }
    });
  • Registration of the graph_cypher tool with the MCP server. Defines title, description, input schema (cypher: string, params: optional record), and marks it read-only. The description notes it's admin-only and enforced read-only via Neo4j executeRead().
    server.registerTool("graph_cypher", {
      title: "Graph Cypher",
      description:
        "Execute a read-only Cypher query against the memory graph. You generate the Cypher — this tool just runs it. Enforced read-only via Neo4j executeRead(). Use for custom queries not covered by other tools. Admin-only (must be the bootstrap tenant) — non-admin tenants would otherwise be able to bypass tenant filtering by writing raw Cypher.",
      inputSchema: {
        cypher: z.string().describe("Cypher query to execute (read-only)"),
        params: z.record(z.string(), z.unknown()).optional().describe("Query parameters"),
      },
      annotations: { readOnlyHint: true },
    }, async (args) => {
  • Input schema for graph_cypher: requires a 'cypher' string (the Cypher query) and optionally a 'params' record for query parameters.
    inputSchema: {
      cypher: z.string().describe("Cypher query to execute (read-only)"),
      params: z.record(z.string(), z.unknown()).optional().describe("Query parameters"),
    },
    annotations: { readOnlyHint: true },
  • The executeCypher method on Neo4jClient. Runs the Cypher query via the private run() method (which uses the Neo4j driver session with WRITE access mode), measures execution time, and returns results with row count and timing.
    async executeCypher(
      cypher: string,
      params: Record<string, unknown> = {},
    ): Promise<{ results: Record<string, unknown>[]; result_count: number; execution_time_ms: number }> {
      const start = Date.now();
      const rows = await this.run(cypher, params);
      const elapsed = Date.now() - start;
      return { results: rows, result_count: rows.length, execution_time_ms: elapsed };
    }
  • The isAdminTenant helper function. Checks if the given tenantId matches the BOOTSTRAP_TENANT_ID environment variable. Used by graph_cypher's handler to gate access to admin-only users.
    export function isAdminTenant(tenantId: string): boolean {
      const bootstrap = process.env.BOOTSTRAP_TENANT_ID;
      if (!bootstrap) return false;
      return tenantId === bootstrap;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true; the description adds detail about enforcement via Neo4j executeRead() and the admin-only constraint, but doesn't contradict annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short, focused sentences. No redundant information, each sentence adds critical context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers purpose, usage guidelines, and security constraints. Lacks explicit mention of return format (query results), but is otherwise sufficient given the tool's generic nature.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters. The description adds minimal value ('You generate the Cypher – this tool just runs it'), so baseline score is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes a read-only Cypher query, distinguishing it from siblings by highlighting it's for custom queries not covered by other tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use (custom queries) and provides strong context on who can use it (admin-only) and why (prevents tenant filtering bypass).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/stevepridemore/graph-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server