Skip to main content
Glama
memgraph

Memgraph MCP Server

Official
by memgraph

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
NameRequiredDescriptionDefault
queryYes

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)}"]
  • 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()
Install Server

Other Tools

Related 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/memgraph/mcp-memgraph'

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