Skip to main content
Glama
Knowledge Graph MCP Server
by aiuluna

Knowledge Graph MCP Server

A Model Context Protocol (MCP) service for creating, managing, analyzing, and visualizing knowledge graphs. This service fully complies with the MCP standard and seamlessly integrates with MCP-compatible AI assistants (such as Claude).

中文文档

Core Features

  • Multiple Graph Types: Support for topology structures, timelines, changelogs, requirement documents, knowledge bases, ontologies, and more

  • Complete Error Handling: Clear error messages and handling suggestions for common issues

  • Resource Management: Support for SVG and Markdown resource association and management

  • Version Status: Support for multiple status management including draft, published, and archived

Related MCP server: GID MCP Server

Installation & Configuration

Installing via Smithery

To install knowledge-graph-mcp for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @aiuluna/knowledge-graph-mcp --client claude

Requirements

  • Node.js >= 16.0.0

  • pnpm >= 7.0.0

Configure Knowledge Graph Directory

Create a directory to store knowledge graph data, for example:

mkdir ~/knowledge_graph

Usage in Cursor

Add the following configuration to your Cursor config file:

{
  "mcpServers": {
    "knowledge-graph": {
      "command": "npx",
      "args": [
        "-y",
        "@aiuluna/knowledge-graph-mcp"
      ],
      "env": {
        "KNOWLEDGE_GRAPH_DIR": "/path/to/your/knowledge_graph/dir"
      }
    }
  }
}

Note:

  • Replace KNOWLEDGE_GRAPH_DIR with your actual knowledge graph storage directory path

  • You can specify a particular version number, such as @0.0.1

Usage in Claude Desktop

Add the following configuration to claude_desktop_config.json:

{
  "mcpServers": {
    "knowledge-graph": {
      "command": "npx",
      "args": [
        "-y",
        "@aiuluna/knowledge-graph-mcp"
      ],
      "env": {
        "KNOWLEDGE_GRAPH_DIR": "/path/to/your/knowledge_graph/dir"
      }
    }
  }
}

Prompt Usage Guide

Project Structure

Prompt files are located in the /src/rules/prompts directory. Please copy these files to your Cursor and add them as default rules for Agent mode (refer to Cursor Rules Configuration):

.cursor/
  └── rules/
      └── graph-query.mdc    # Knowledge graph query prompt file

Using Agent Mode

When using Agent mode in Cursor, you can trigger knowledge graph queries by:

  1. Type /ck command in the editor

  2. The Agent will automatically invoke the prompt defined in @graph-query.mdc

  3. The prompt will:

    • Analyze current context

    • Query relevant knowledge graph nodes

    • Generate summary content

    • Integrate query results into the conversation

Other Rules

The project also includes prompts for generating hand-drawn style graphics and Markdown documents as knowledge graph resources. Since Cursor doesn't support the MCP standard for prompts, this project uses tools to obtain these rules. You can also integrate them into Cursor's rules like above and modify them to your desired style for use in Cursor Agent mode.

Tool List

Graph Management

  1. create_graph

    • Create a new knowledge graph

    • Parameters:

      • name (string): Graph name

      • description (string, optional): Graph description

      • type (string): Graph type (topology/timeline/changelog/requirement/kb/ontology)

  2. list_graphs

    • List all knowledge graphs

    • Parameters:

      • status (string, optional): Filter by status (draft/published/archived)

      • type (string, optional): Filter by type

  3. publish_graph

    • Publish a knowledge graph

    • Parameters:

      • graphId (string): Graph ID

Node Management

  1. add_node

    • Add a node to the graph

    • Parameters:

      • graphId (string): Graph ID

      • type (string): Node type

      • name (string): Node name

      • description (string, optional): Node description

      • filePath (string, optional): Associated file path

      • metadata (object, optional): Node metadata

  2. update_node

    • Update node information

    • Parameters:

      • graphId (string): Graph ID

      • nodeId (string): Node ID

      • name (string, optional): New node name

      • description (string, optional): New node description

      • filePath (string, optional): New file path

      • metadata (object, optional): New metadata

  3. delete_node

    • Delete a node

    • Parameters:

      • graphId (string): Graph ID

      • nodeId (string): Node ID

      • confirmDelete (boolean): Delete confirmation

  4. get_node_details

    • Get detailed node information

    • Parameters:

      • graphId (string): Graph ID

      • nodeId (string): Node ID

Edge Management

  1. add_edge

    • Add an edge

    • Parameters:

      • graphId (string): Graph ID

      • type (string): Edge type

      • sourceId (string): Source node ID

      • targetId (string): Target node ID

      • label (string, optional): Edge label

      • weight (number, optional): Edge weight

      • metadata (object, optional): Edge metadata

  2. update_edge

    • Update edge information

    • Parameters:

      • graphId (string): Graph ID

      • edgeId (string): Edge ID

      • label (string, optional): New edge label

      • weight (number, optional): New edge weight

      • metadata (object, optional): New metadata

  3. delete_edge

    • Delete an edge

    • Parameters:

      • graphId (string): Graph ID

      • edgeId (string): Edge ID

      • confirmDelete (boolean): Delete confirmation

Resource Management

  1. get_creation_guidelines

    • Get resource creation guidelines

    • Parameters:

      • type (string): Guideline type (svg/markdown/all)

  2. save_resource

    • Save a resource

    • Parameters:

      • graphId (string): Graph ID

      • nodeId (string, optional): Associated node ID

      • resourceType (string): Resource type (svg/markdown)

      • title (string): Resource title

      • description (string, optional): Resource description

      • content (string): Resource content

  3. update_resource

    • Update resource information

    • Parameters:

      • graphId (string): Graph ID

      • resourceId (string): Resource ID

      • name (string, optional): New resource name

      • title (string, optional): New resource title

      • description (string, optional): New resource description

  4. delete_resource

    • Delete a resource

    • Parameters:

      • graphId (string): Graph ID

      • resourceId (string): Resource ID

      • confirmDelete (boolean): Delete confirmation

  5. unlink_resource

    • Unlink a resource from a node

    • Parameters:

      • graphId (string): Graph ID

      • nodeId (string): Node ID

      • resourceId (string): Resource ID

Development

# Install dependencies
pnpm install

# Development mode
pnpm dev

# Build project
pnpm build

# Run tests
pnpm test

# Code check
pnpm lint

Error Handling

The service uses a standard error handling mechanism. All errors are logged to the md/error_log.txt file, including timestamps, error messages, and stack traces.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Available Tools

15 tools
add_edgeA

Add edges in the knowledge graph, connecting two nodes to build a relationship network. Edges represent relationship types between nodes, such as dependencies, containment, associations, etc. Prerequisites:

  1. Must first create a graph (using create_graph)

  2. Source and target nodes must already exist

  3. Edge type must match the graph type

Usage recommendations:

  1. First use list_graphs to get graph and node information

  2. Confirm both source and target nodes exist and their types match

  3. Choose appropriate edge type based on graph type

  4. Add meaningful labels to edges to help understand relationships

  5. If relationships have varying strengths, use the weight parameter

Return data:

  • data: Newly created edge information

    • id: Edge ID

    • type: Edge type

    • sourceId: Source node ID

    • targetId: Target node ID

    • label: Edge label

    • weight: Edge weight

Inputs: graphId (required), type (required), sourceId (required), targetId (required), +2 more.

add_nodeA

Add a node to the knowledge graph. Nodes are the basic units of the graph, and different types of graphs support different types of nodes. Use cases:

  1. Create component or module nodes in topology graphs

  2. Add event or decision nodes in timeline graphs

  3. Create requirement or feature nodes in requirement documents

  4. Build concept hierarchies in knowledge bases

Usage recommendations:

  1. First create the graph using create_graph

  2. Select the appropriate node type based on graph type

  3. Provide meaningful names and descriptions

  4. Link related files when applicable

  5. Add metadata for additional structured information

Return data:

  • data: Created node information

    • id: Node ID

    • type: Node type

    • name: Node name

    • description: Node description

    • createdAt: Creation time

Inputs: graphId (required), type (required), name (required), description, +2 more.

create_graphA

Create a new knowledge graph. Supports multiple graph types such as topology, timeline, changelog, requirement documentation, etc. Design guidelines for each graph type:

  • topology: Used to represent dependencies between system components and modules. Recommended to first create main module nodes, then add component nodes, and finally represent relationships through edges like calls, dependencies, and containment

  • timeline: Used to record important project events and decisions. Recommended to add event nodes in chronological order and link related personnel and decisions

  • changelog: Used to track change history of features and components. Recommended to create nodes for each significant change, marking change types and impact scope

  • requirement: Used for requirement management and tracking. Recommended to first create high-level requirements, then break down into specific features, and finally link to responsible persons and iterations

  • knowledge_base: Used to build domain knowledge systems. Recommended to start from core concepts and gradually expand related concepts and relationships

  • ontology: Used for formal representation of domain concepts and relationships, suitable for building standardized knowledge models

Inputs: name (required), description, type.

delete_edgeA

Delete edges from the knowledge graph. This tool must be used in conjunction with list_graphs and get_node_details tools, and the operation cannot be undone. Use cases:

  1. Delete incorrectly created relationships

  2. Update relationship structure between nodes

  3. Clean up redundant relationships when restructuring the graph

Usage recommendations:

  1. First call list_graphs to get target graph information

  2. Use get_node_details to get edge details

  3. Confirm deletion won't break important relationship structures

  4. Set confirmDelete to true to confirm deletion

Important notes:

  • Deleting edges won't affect related nodes

  • Need to call get_node_details again to view updated relationships

Return data:

  • data: Deletion result

    • id: Deleted edge ID

    • deletedAt: Deletion time

Inputs: graphId (required), edgeId (required), confirmDelete (required).

delete_nodeA

Delete nodes from the knowledge graph. This tool must be used in conjunction with list_graphs tool, and the operation cannot be undone. Use cases:

  1. Delete incorrectly created nodes

  2. Delete nodes that are no longer needed

  3. Delete redundant nodes when restructuring the graph

Usage recommendations:

  1. First call list_graphs to get target graph and node information

  2. Use get_node_details to check node's associated resources and relationships

  3. Confirm deletion won't affect other important nodes

  4. Set confirmDelete to true to confirm deletion

  5. Recommended to backup important data before deletion

Important notes:

  • Deleting a node will also delete all edges related to that node

  • If the node has associated resources, they won't be deleted but will be unlinked

Return data:

  • data: Deletion result

    • id: Deleted node ID

    • name: Node name

    • type: Node type

    • deletedAt: Deletion time

Inputs: graphId (required), nodeId (required), confirmDelete (required).

delete_resourceA

Delete resources from the knowledge graph. This tool must be used in conjunction with list_graphs and get_node_details tools, and the operation cannot be undone. Use cases:

  1. Delete outdated resource files

  2. Clean up unnecessary documents

  3. Remove incorrectly created resources

Usage recommendations:

  1. First call list_graphs to get target graph information

  2. Use get_node_details to confirm resource associations

  3. Confirm deletion won't affect other nodes

  4. Set confirmDelete to true to confirm deletion

  5. Recommended to backup important resources before deletion

Important notes:

  • Deleting a resource will also delete the physical file

  • Will automatically unlink from all nodes

  • This operation cannot be recovered

Return data:

  • data: Deletion result

    • id: Deleted resource ID

    • type: Resource type

    • deletedAt: Deletion time

Inputs: graphId (required), resourceId (required), confirmDelete (required).

get_creation_guidelinesA

Get creation guidelines and standards for SVG graphics and Markdown documents. This tool is a prerequisite for the save_resource tool and must be called before creating and saving any resources. Use cases:

  1. Get drawing standards before creating SVG visualizations

  2. Get format requirements before creating Markdown documents

  3. Get complete guidelines before batch resource creation

Usage recommendations:

  1. Call this tool before starting any resource creation

  2. Carefully read and follow the naming rules and directory structure

  3. Create resources according to guidelines, then use save_resource tool

  4. Recommended to save guidelines for team reference

Return data:

  • data: Guidelines content

    • guidelines: Guidelines text content

      • File naming rules

      • Directory structure requirements

      • Format specifications

      • Style guide

    • type: Guidelines type (svg/markdown/all)

    • version: Guidelines version

Inputs: type (required).

get_node_detailsA

Get detailed information about a specific node in the graph. This tool must be used in conjunction with the list_graphs tool, as the nodeId must be obtained from the list_graphs response. Use cases:

  1. View complete node attributes

  2. Check associated resources (SVG/Markdown)

  3. Analyze node relationships with others

  4. Check current state before modifying a node

Usage recommendations:

  1. First call list_graphs to get the node list of the target graph

  2. Get the required nodeId from the returned nodes array

  3. Use the obtained graphId and nodeId to call this tool

  4. Check the returned relationship data to determine if further action is needed

Return data:

  • data: Node details

    • id: Node ID

    • name: Node name

    • type: Node type

    • description: Node description

    • filePath: Associated file path

    • metadata: Node metadata

    • resources: Associated resource list

      • id: Resource ID

      • type: Resource type (svg/markdown)

      • title: Resource title

    • relationships: Relationship list

      • id: Edge ID

      • type: Edge type

      • targetNode: Target node information

Inputs: graphId (required), nodeId (required).

list_graphsA

List all knowledge graphs with support for filtering by status and type. This is the main tool for getting information about existing graphs and an important path for obtaining node IDs. Use cases:

  1. View all available graphs and their basic information

  2. Get the node list of a specific graph for subsequent edge addition or node detail queries

  3. Filter graphs by status, such as viewing all drafts or published graphs

  4. Filter graphs by type, such as viewing only topology or timeline graphs

Usage recommendations:

  1. First call this tool to get the graph list and node information

  2. Get the required graph ID and node ID from the returned data

  3. Use these IDs to call other tools (like add_edge, get_node_details)

  4. Recommended to use this tool to confirm the target graph's status before performing any node or edge operations

Return data:

  • data: List of graphs, each graph contains:

    • id: Graph ID (used for graphId parameter in other tools)

    • name: Graph name

    • description: Graph description

    • type: Graph type

    • status: Graph status

    • nodesCount: Number of nodes

    • edgesCount: Number of edges

    • createdAt: Creation time

    • updatedAt: Update time

    • publishedAt: Publication time (if published)

    • nodes: Node list, each node contains:

      • id: Node ID (used for add_edge and get_node_details tools)

      • name: Node name

      • type: Node type

Inputs: status, type.

publish_graphA

Publish a knowledge graph, changing its status from draft to published. Published graphs can still be modified, but it's recommended to track important changes through version management. Prerequisites:

  1. Graph must exist and be in draft status

  2. Recommended to ensure graph content is complete before publishing

  3. Ensure all necessary nodes and edges have been added

Usage recommendations:

  1. First use list_graphs to check the current status of the graph

  2. Use get_node_details to check the completeness of key nodes

  3. Review the graph structure before publishing

  4. Record publication time for version management

  5. Notify relevant team members after publication

Return data:

  • data: Published graph information

    • id: Graph ID

    • name: Graph name

    • type: Graph type

    • status: Published

    • publishedAt: Publication time

Inputs: graphId (required).

save_resourceA

Save AI-generated SVG graphics or Markdown documents to the knowledge graph. This tool must be used in conjunction with get_creation_guidelines and list_graphs tools. Use cases:

  1. Save SVG visualization representation of the graph

  2. Save Markdown documents related to nodes

  3. Batch save multiple resource files

Usage recommendations:

  1. First call get_creation_guidelines to get resource creation standards

  2. Use list_graphs to get target graph ID and node ID (if needed)

  3. Create resource content according to standards

  4. Use this tool to save the resource

  5. After saving, use get_node_details to check resource association status

Return data:

  • data: Saved resource information

    • id: Resource ID

    • type: Resource type (svg/markdown)

    • title: Resource title

    • description: Resource description

    • nodeId: Associated node ID (if any)

    • createdAt: Creation time

Inputs: graphId (required), resourceType (required), title (required), content (required), +2 more.

update_edgeA

Modify edges in the knowledge graph. This tool must be used in conjunction with list_graphs and get_node_details tools. Use cases:

  1. Update edge label information

  2. Adjust edge weight values

  3. Update edge metadata information

Usage recommendations:

  1. First call list_graphs to get target graph information

  2. Use get_node_details to view edge list of related nodes

  3. Only update fields that need to be modified, keep others unchanged

  4. After updating, call get_node_details again to confirm changes

Return data:

  • data: Updated edge information

    • id: Edge ID

    • type: Edge type

    • sourceId: Source node ID

    • targetId: Target node ID

    • label: Edge label

    • weight: Edge weight

    • metadata: Edge metadata

    • updatedAt: Update time

Inputs: graphId (required), edgeId (required), label, weight, +1 more.

update_nodeA

Modify nodes in the knowledge graph. This tool must be used in conjunction with list_graphs and get_node_details tools. Use cases:

  1. Update basic node information (name, description, etc.)

  2. Update file paths associated with nodes

  3. Update node metadata information

Usage recommendations:

  1. First call list_graphs to get target graph and node ID

  2. Use get_node_details to check current node status

  3. Only update fields that need to be modified, keep others unchanged

  4. After updating, call get_node_details again to confirm changes

Return data:

  • data: Updated node information

    • id: Node ID

    • name: Node name

    • type: Node type

    • description: Node description

    • filePath: Associated file path

    • metadata: Node metadata

    • updatedAt: Update time

Inputs: graphId (required), nodeId (required), name, description, +2 more.

update_resourceA

Update resource information in the knowledge graph. This tool must be used in conjunction with list_graphs and get_node_details tools. Use cases:

  1. Modify resource title or description

  2. Update resource metadata information

  3. Improve resource documentation

Usage recommendations:

  1. First call list_graphs to get target graph information

  2. Use get_node_details to check current resource information

  3. Only update fields that need to be modified

  4. Maintain consistency in resource naming

Return data:

  • data: Updated resource information

    • id: Resource ID

    • name: Resource name

    • title: Resource title

    • description: Resource description

    • updatedAt: Update time

Inputs: graphId (required), resourceId (required), name, title, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 15 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose targeting specific graph elements (nodes, edges, graphs, resources) with precise actions (add, delete, update, list, get). No overlap exists; for example, delete_edge, delete_node, and delete_resource handle different entities, and update tools are clearly separated by target. The descriptions reinforce these distinctions, making misselection unlikely.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case throughout, such as add_edge, list_graphs, update_node, and get_node_details. The verbs (add, create, delete, get, list, publish, save, unlink, update) are used predictably across similar operations, enhancing readability and predictability for agents.

    Tool Count5/5

    With 15 tools, the count is well-scoped for a knowledge graph management server, covering CRUD operations for graphs, nodes, edges, and resources, plus auxiliary tools like publish_graph and get_creation_guidelines. Each tool earns its place by addressing specific needs in graph lifecycle management, avoiding redundancy while ensuring comprehensive coverage.

    Completeness5/5

    The tool set provides complete CRUD/lifecycle coverage for knowledge graphs, including creation (create_graph), modification (add/update/delete for nodes, edges, resources), querying (list_graphs, get_node_details), and publishing (publish_graph). No obvious gaps exist; tools like get_creation_guidelines and unlink_resource address nuanced needs, ensuring agents can handle all typical workflows without dead ends.

    Related MCP Connectors

    Related MCP Servers