run_query
Execute queries on Memgraph database using the Model Context Protocol, enabling interaction with graph data through natural language input.
Instructions
Run a query against Memgraph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- server.py:25-25 (registration)Registration of the 'run_query' tool using the @mcp.tool() decorator.@mcp.tool()
- server.py:26-33 (handler)Handler function that executes the 'run_query' tool logic by calling execute_query and handling errors.def run_query(query: str) -> list: """Run a query against Memgraph""" logger.info(f"Running query: {query}") try: result = execute_query(query) return result except Exception as e: return [f"Error: {str(e)}"]
- server.py:19-22 (helper)Helper function to execute Cypher queries on Memgraph using the Neo4j driver.def execute_query(query): """Helper function to execute a query on Memgraph""" with driver.session() as session: return session.run(query).data()