Package com.tnsai.mcp.database
Class Neo4jMcpClient
java.lang.Object
com.tnsai.mcp.database.Neo4jMcpClient
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 Summary
ConstructorsConstructorDescriptionNeo4jMcpClient(McpClient mcpClient) Creates a new Neo4jMcpClient wrapping the given MCP client. -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodeexecuteCypher(String query) Executes a Cypher query.Returns the underlying MCP client.com.fasterxml.jackson.databind.JsonNodeGets the graph database schema.booleanChecks if the Neo4j MCP server is available.com.fasterxml.jackson.databind.JsonNodeLists all node labels in the graph database.
-
Constructor Details
-
Neo4jMcpClient
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
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
Lists all node labels in the graph database.- Returns:
- the list of node labels as JSON
- Throws:
IOException- if the MCP call fails
-
getSchema
Gets the graph database schema.- Returns:
- the schema as JSON
- Throws:
IOException- if the MCP call fails
-
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
-