Class Neo4jMcpClient

java.lang.Object
com.tnsai.mcp.database.Neo4jMcpClient

public class Neo4jMcpClient extends Object
Client for Neo4j's MCP server.

Provides convenience methods for common Neo4j operations by wrapping MCP tool calls to a Neo4j MCP server. All operations are performed through the underlying McpClient.

Example usage:


 McpClient mcpClient = McpClient.create(transport);
 mcpClient.connect();
 mcpClient.initialize();

 Neo4jMcpClient neo4j = new Neo4jMcpClient(mcpClient);
 JsonNode schema = neo4j.getSchema();
 JsonNode result = neo4j.executeCypher("MATCH (n:Person) RETURN n LIMIT 10");
 
See Also:
  • Constructor Details

    • Neo4jMcpClient

      public Neo4jMcpClient(McpClient mcpClient)
      Creates a new Neo4jMcpClient wrapping the given MCP client.
      Parameters:
      mcpClient - the MCP client connected to a Neo4j MCP server
      Throws:
      IllegalArgumentException - if mcpClient is null
  • Method Details

    • executeCypher

      public com.fasterxml.jackson.databind.JsonNode executeCypher(String query) throws IOException
      Executes a Cypher query.
      Parameters:
      query - the Cypher query to execute
      Returns:
      the query results as JSON
      Throws:
      IOException - if the MCP call fails
    • listNodeLabels

      public com.fasterxml.jackson.databind.JsonNode listNodeLabels() throws IOException
      Lists all node labels in the graph database.
      Returns:
      the list of node labels as JSON
      Throws:
      IOException - if the MCP call fails
    • getSchema

      public com.fasterxml.jackson.databind.JsonNode getSchema() throws IOException
      Gets the graph database schema.
      Returns:
      the schema as JSON
      Throws:
      IOException - if the MCP call fails
    • getMcpClient

      public McpClient getMcpClient()
      Returns the underlying MCP client.
      Returns:
      the MCP client
    • isAvailable

      public boolean isAvailable()
      Checks if the Neo4j MCP server is available.
      Returns:
      true if the MCP client is connected and initialized