Skip to main content
Glama
Knowledge Graph MCP Server

Knowledge Graph MCP Server

by pitchmuc

Knowledge Graph MCP Server

Model Context Protocol (MCP) server that exposes a fictional CRM knowledge graph — enterprise Accounts and customer Contacts — for querying from Claude, ChatGPT, Adobe Coworker, or any other MCP-compatible client.

The graph is a plain Turtle/RDF file (data/knowledge_graph.ttl), loaded into memory with rdflib and queried via SPARQL. All data is synthetic/made-up — it does not represent any real company or person.

This server mirrors the deployment setup used by the sibling intervals-mcp-server project (Docker + Render + optional OAuth), swapping a REST API integration for a self-contained knowledge graph.

What's in the graph?

  • 8 fictional enterprise accounts across industries (manufacturing, financial services, software, retail, healthcare, logistics, energy, education), each with tier, region, ARR, employee count, health score, renewal date, and account owner.

  • 19 fictional contacts linked to those accounts, each with a job title, sales role (Economic Buyer / Champion / Influencer / User), email, phone, champion flag, sentiment, and last-contacted date.

See src/kg_mcp_server/tools/schema.py (get_graph_schema tool) for the full property list and namespace.

Related MCP server: EspoCRM MCP Server

The fastest way to get started is to deploy the server to Render as a Docker Web Service. No local installation required.

1. Create a Web Service on Render

  1. Push this folder to its own GitHub repository.

  2. Go to render.com → New → Web Service (or use the included render.yaml with New → Blueprint).

  3. Connect your GitHub repository.

  4. Configure the service:

    • Name: kg-mcp-server (or your preferred name)

    • Runtime: Docker

    • Instance Type: Free tier works fine

💤 Free tier cold starts: Render free-tier services sleep after 15 minutes of inactivity. The first request after sleeping may take 30-60 seconds while the container restarts and the graph reloads. Subsequent requests are fast.

2. Set Environment Variables

In the Render dashboard under Environment, add:

Key

Value

Description

MCP_TRANSPORT

http

Enables the remote transport (streamable HTTP)

FASTMCP_HOST

0.0.0.0

Bind to all interfaces (required inside Docker)

Optional — enable OAuth 2.0 to protect the endpoint:

Key

Value

Description

MCP_CLIENT_ID

kg-mcp

OAuth client ID; must match the connector config exactly

MCP_CLIENT_SECRET

<random secret>

OAuth client secret / access token; must match the connector

MCP_SERVER_URL

https://your-service-name.onrender.com

Public HTTPS URL (no /mcp); required for OAuth discovery

3. Deploy and Verify

  1. Click Create Web Service — Render will build the Docker image and deploy

  2. Wait for the build to complete (green status)

  3. Note your service URL: https://your-service-name.onrender.com

  4. Test by opening https://your-service-name.onrender.com/mcp in a browser — you should get a response from the server

⚠️ Security Warning: Without OAuth, your Render endpoint is publicly accessible — anyone who discovers the URL can query the knowledge graph (read-only; there is no write/mutate capability). Either enable OAuth or do not share your service URL publicly.

Connecting Claude

  1. Open Claude → Settings → Integrations (or MCP Servers)

  2. Click Add

  3. Fill in:

    • Name: Knowledge Graph

    • URL: https://your-service-name.onrender.com/mcp (must end with /mcp)

    • If OAuth is enabled, also set OAuth Client ID / OAuth Client Secret

Open a new conversation and ask "What MCP tools do you have available?" to confirm the connection.

Connecting ChatGPT / Adobe Coworker / other MCP clients

Any MCP-compatible client that supports remote (Streamable HTTP) servers can connect the same way:

  • MCP Server URL: https://your-service-name.onrender.com/mcp

  • OAuth Client ID / Secret if enabled

Available Tools

  • get_graph_schema — describe the graph's classes, properties, and namespace

  • get_graph_stats — triple/entity counts for the loaded graph

  • list_accounts — list/filter accounts by industry, tier, region, health score

  • search_accounts — free-text search across accounts

  • get_account — full detail for one account, including its contacts

  • list_contacts_for_account — list contacts working at a given account

  • search_contacts — free-text search across contacts

  • get_contact — full detail for one contact

  • run_sparql_query — arbitrary read-only SPARQL SELECT/ASK query

There is also an MCP resource, kg://guide, with a usage guide LLM clients can load at the start of a conversation.

Troubleshooting Render Deployment

  • Service won't start — Check Render logs for build errors.

  • Claude/ChatGPT can't connect — Verify the URL ends with /mcp and is publicly accessible. Try opening it in a browser.

  • "Authorization failed" with OAuth — MCP_CLIENT_ID/MCP_CLIENT_SECRET must match the connector exactly (case-sensitive), MCP_SERVER_URL must be the public HTTPS URL without /mcp, and the connector URL must end with /mcp.

  • Free tier cold starts — first request after sleeping may take 30-60 seconds.


Requirements

  • Python 3.12 or higher

  • uv (recommended package manager)

1. Install uv

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Clone and install

cd kg_mcp_server
uv venv --python 3.12
source .venv/bin/activate   # Windows: .venv\Scripts\activate
uv sync --all-extras

Configure Claude Desktop (stdio)

mcp install src/kg_mcp_server/server.py --name "Knowledge Graph"

Or manually add to claude_desktop_config.json:

{
  "mcpServers": {
    "Knowledge Graph": {
      "command": "uv",
      "args": [
        "run", "--with", "mcp[cli]",
        "--with-editable", "/path/to/kg_mcp_server",
        "mcp", "run", "/path/to/kg_mcp_server/src/kg_mcp_server/server.py"
      ]
    }
  }
}

Running over HTTP locally (for ChatGPT / remote testing)

export FASTMCP_HOST=127.0.0.1 FASTMCP_PORT=8000 MCP_TRANSPORT=http
python src/kg_mcp_server/server.py

Forward the port with a tunnel (e.g. ngrok http 8000) to give a remote client a public URL.

Editing the knowledge graph

Edit data/knowledge_graph.ttl directly — it's plain Turtle. Restart the server (or call kg_mcp_server.graph.store.reload_graph()) to pick up changes. Use KG_GRAPH_PATH to point at a different file entirely.

Development and testing

uv sync --all-extras
ruff check .
mypy src tests
pytest -v tests

License

The GNU General Public License v3.0

Available Tools

9 tools
get_accountA
Read-only

Get full details for a single account, including its contacts.

Args: account: The account identifier (e.g. "acct-atlasforge"), or a name/substring to look up (e.g. "AtlasForge" or "atlasforge manufacturing"). include_contacts: Whether to also list contacts linked to this account (optional, defaults to True).

Inputs: account (required), include_contacts. Returns: result

get_contactA
Read-only

Get full details for a single contact.

Args: contact: The contact identifier (e.g. "contact-adriana-koll"), or a name/substring to look up (e.g. "Adriana Koll" or "koll").

Inputs: contact (required). Returns: result

get_graph_schemaA
Read-only

Describe the knowledge graph's classes, properties, and namespace.

Call this before writing a raw SPARQL query with run_sparql_query, or to understand what fields are available on accounts and contacts.

Inputs: no named parameters. Returns: result

get_graph_statsA
Read-only

Return basic statistics about the loaded knowledge graph (triple/entity counts).

Inputs: no named parameters. Returns: result

list_accountsA
Read-only

List enterprise accounts in the knowledge graph, optionally filtered.

Args: industry: Case-insensitive substring match on industry (optional). tier: Exact match on account tier, e.g. "Strategic", "Enterprise", "Mid-Market" (optional). region: Exact match on region code, e.g. "NA", "EMEA", "APAC" (optional). min_health_score: Only return accounts with healthScore >= this value (optional, defaults to 0 i.e. no filtering).

Inputs: tier, region, industry, min_health_score. Returns: result

list_contacts_for_accountA
Read-only

List contacts (people) who work at a given account.

Args: account: The account identifier (e.g. "acct-atlasforge") or a name/substring (e.g. "AtlasForge"). role: Optional exact match on contact role, e.g. "Economic Buyer", "Champion", "Influencer", "User".

Inputs: account (required), role. Returns: result

run_sparql_queryA
Read-only

Run a read-only SPARQL SELECT or ASK query directly against the knowledge graph.

Use this for questions the higher-level account/contact tools can't answer, e.g. joins, aggregations, or custom filters. The graph uses the crm: prefix (http://example.org/crm#) for all classes and properties — call get_graph_schema() first to see available classes and properties.

Only SELECT and ASK queries are permitted; INSERT/DELETE/DROP/LOAD/CREATE are rejected. PREFIX crm: <http://example.org/crm#> is available automatically but may also be declared explicitly.

Args: query: The SPARQL query text, e.g. "SELECT ?name ?arrUsd WHERE { ?a a crm:Account ; crm:name ?name ; crm:arrUsd ?arrUsd . } ORDER BY DESC(?arrUsd) LIMIT 5"

Inputs: query (required). Returns: result

search_accountsA
Read-only

Search accounts by a keyword matched against name, industry, or account owner.

Args: keyword: Free-text keyword to search for (case-insensitive substring match).

Inputs: keyword (required). Returns: result

search_contactsA
Read-only

Search contacts by keyword matched against name, job title, or account name.

Args: keyword: Free-text keyword to search for (case-insensitive substring match). role: Optional exact match on contact role, e.g. "Economic Buyer", "Champion", "Influencer", "User".

Inputs: keyword (required), role. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 9 tools

    Disambiguation4/5

    search_accounts (keyword) vs list_accounts (structured filters) both return account lists but the descriptions clarify the distinct filtering modes. Similarly search_contacts vs list_contacts_for_account are differentiated by scope. run_sparql_query has clear escape-hatch positioning relative to the higher-level tools.

    Naming Consistency5/5

    All nine tools follow a consistent snake_case verb_noun pattern (get_graph_schema, search_accounts, list_accounts, get_contact, run_sparql_query, etc.). No mixed conventions or vague verbs.

    Tool Count5/5

    Nine tools is well-scoped for a read-only CRM knowledge graph: two meta tools, three account tools, three contact tools, and a raw query escape hatch. Each earns its place.

    Completeness4/5

    Account and contact lifecycles are well covered for reading (list/search/get for both, plus schema, stats, and a raw SPARQL escape hatch for aggregations/joins). The surface is read-only by design, so no create/update/delete, and a bulk list-all-contacts view is missing but reachable via search_contacts or SPARQL.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A remote MCP server that connects Claude to a Twenty CRM workspace, enabling users to interact with CRM objects (People, Companies, Opportunities, and custom objects) through schema-driven tools for querying, creating, updating, and deleting records.
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      A local, read-only MCP server for Claude Desktop that provides 16 tools to search and read EspoCRM accounts, contacts, opportunities, and related emails via a strict allowlist.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A read-only MCP server providing structured access to CRM data (companies, contacts, deals, activities) backed by SQLite. It enables LLMs to search contacts and deals, view full company accounts, find stale deals, and get pipeline summaries.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients such as Cursor and Claude Desktop to query a GRC platform over stdio or HTTP, with read-only access by default and opt-in create, update, and delete tools subject to platform authorization.
      3
      Apache 2.0