Skip to main content
Glama
Tobarrientos2

Neo4j MCP Server

neo4j-query

Execute Cypher queries on Neo4j databases to retrieve, create, update, or delete graph data through AI assistants.

Instructions

Execute a Cypher query against the Neo4j database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe Cypher query to execute
parametersNoQuery parameters (optional)

Implementation Reference

  • The executeQuery method implements the core logic of the neo4j-query tool by running the Cypher query on the Neo4j database and returning the records.
    async executeQuery(query: string, parameters: Record<string, any> = {}) {
        const session = this.driver.session();
        try {
            const result = await session.run(query, parameters);
            return result.records;
        } finally {
            await session.close();
        }
  • The tool schema definition including name, description, and input schema for the neo4j-query tool.
    {
        name: "neo4j-query",
        description: "Execute a Cypher query against the Neo4j database",
        inputSchema: {
            type: "object",
            properties: {
                query: {
                    type: "string",
                    description: "The Cypher query to execute"
                },
                parameters: {
                    type: "object",
                    description: "Query parameters (optional)",
                    additionalProperties: true
                }
            },
            required: ["query"]
        }
    }
  • src/index.ts:126-131 (registration)
    Switch case dispatching calls to the neo4j-query tool handler within the CallToolRequestSchema handler.
    case "neo4j-query":
        response = await this.executeQuery(
            args.query as string,
            args.parameters as Record<string, any>
        );
        break;
  • Helper function that formats the Neo4j query result records into a human-readable text output.
    function formatResults(records: neo4j.Record[]) {
        if (!records || records.length === 0) {
            return "No results found.";
        }
    
        const output: string[] = ["Results:"];
        
        records.forEach((record, index) => {
            output.push(`\nRecord ${index + 1}:`);
            record.keys.forEach(key => {
                const value = record.get(key);
                output.push(`${String(key)}: ${formatValue(value)}`);
            });
        });
    
        return output.join('\n');
    }
  • Helper function to format Neo4j-specific data types (nodes, relationships, paths, etc.) into strings.
    function formatValue(value: any): string {
        if (value === null || value === undefined) {
            return 'null';
        }
    
        if (neo4j.isNode(value)) {
            return `Node(id=${value.identity}, labels=[${value.labels.join(', ')}], properties=${JSON.stringify(value.properties)})`;
        }
    
        if (neo4j.isRelationship(value)) {
            return `Relationship(id=${value.identity}, type=${value.type}, properties=${JSON.stringify(value.properties)})`;
        }
    
        if (neo4j.isPath(value)) {
            return `Path(length=${value.segments.length}, nodes=${value.segments.length + 1})`;
        }
    
        if (Array.isArray(value)) {
            return `[${value.map(formatValue).join(', ')}]`;
        }
    
        if (typeof value === 'object') {
            return JSON.stringify(value);
        }
    
        return String(value);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Execute' implies a write operation, the description doesn't clarify whether this tool can perform read-only queries, mutations, or both. It lacks information about permissions required, transaction handling, result formats, or potential side effects like data modification or performance impacts.

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?

The description is a single, efficient sentence that communicates the core functionality without unnecessary words. It's appropriately sized for a straightforward tool and is front-loaded with the essential information. Every word earns its place in this minimal description.

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

Completeness2/5

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

For a database query execution tool with no annotations and no output schema, the description is insufficient. It doesn't explain what kind of results to expect, error handling, security considerations, or whether queries are read-only or can modify data. The combination of a powerful database tool with minimal description creates significant gaps in understanding.

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 description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. This meets the baseline expectation when schema coverage is complete, but doesn't provide extra value like Cypher syntax examples or parameter format guidance.

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

Purpose4/5

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

The description clearly states the action ('Execute') and target resource ('Cypher query against the Neo4j database'), making the purpose immediately understandable. It lacks sibling differentiation, but since there are no sibling tools on this server, this doesn't reduce clarity. The description avoids tautology by specifying what type of query and database are involved.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or limitations. It simply states what the tool does without context about appropriate use cases. With no sibling tools, the need for differentiation is reduced, but general usage context is still missing.

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/Tobarrientos2/neo4j-mcpserver'

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