Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ This server implements the [Model Context Protocol (MCP)](https://modelcontextpr
- FalkorDB instance (running locally or remotely)
- Claude Desktop app (for AI integration)

### Running from npm

Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):

```json
{
"mcpServers": {
"falkordb": {
"command": "npx",
"args": [
"-y",
"falkordb-mcpserver@latest"
],
"env": {
"FALKORDB_HOST": "localhost",
"FALKORDB_PORT": "6379",
"FALKORDB_USERNAME": "",
"FALKORDB_PASSWORD": ""
}
}
}
}
```

### Installation

1. **Clone and install:**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "falkordb-mcpserver",
"version": "1.0.0",
"version": "1.0.1",
"description": "Model Context Protocol server for FalkorDB graph databases - enables AI assistants to query and manage graph data using natural language",
"main": "dist/index.js",
"type": "module",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import { falkorDBService } from './services/falkordb.service.js';
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
Expand Down
105 changes: 105 additions & 0 deletions src/mcp/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,113 @@ Please proceed with querying the memory graph for information about "${query}".`
)
}

function registerGraphReorganizationPrompt(server: McpServer): void {
server.registerPrompt(
"graph_reorganization",
{
title: "Graph Reorganization",
description: "Analyze and reorganize the graph structure for optimal performance and usability"
},
async () => {
const reorganizationMessage = `# Graph Reorganization Task

You are working with a FalkorDB graph database to optimize its structure for better performance and usability.

**Your task is to:**

1. **Analyze Current Structure**: Examine the graph to identify structural issues:
- Find nodes with excessive connections (hubs with >50 relationships)
- Identify disconnected components or islands
- Locate duplicate or near-duplicate nodes
- Find outdated or stale connections
- Analyze relationship distribution and patterns

2. **Performance Optimization**: Based on the analysis, implement improvements:
- **Merge duplicate nodes**: Combine nodes with similar properties or content
- **Create strategic hubs**: Add intermediate nodes to reduce direct connections
- **Remove dead connections**: Delete relationships to non-existent or irrelevant nodes
- **Add semantic clustering**: Group related nodes under topic or category nodes
- **Optimize relationship types**: Ensure relationship labels are descriptive and indexed

3. **Usability Enhancement**: Improve graph navigation and querying:
- **Add metadata nodes**: Create nodes that summarize clusters or topics
- **Establish clear hierarchies**: Organize nodes in logical parent-child relationships
- **Create shortcut relationships**: Add direct paths for frequently accessed connections
- **Implement time-based organization**: Group nodes by temporal relevance

4. **Validation and Testing**: After reorganization:
- Verify all critical paths remain intact
- Test common query patterns for performance
- Ensure no data loss occurred during restructuring
- Document changes made for future reference

**Optimization Strategies by Goal:**

**Performance Focus:**
- Minimize query traversal depth
- Balance node degree distribution
- Create efficient index structures
- Reduce redundant relationships

**Usability Focus:**
- Improve semantic organization
- Add descriptive metadata
- Create intuitive navigation paths
- Enhance discoverability

**Balanced Approach:**
- Apply moderate optimizations from both areas
- Prioritize changes with highest impact/effort ratio

**Analysis Queries to Run:**
\`\`\`cypher
// Find high-degree nodes
MATCH (n)-[r]-()
WITH n, count(r) as degree
Comment thread
SecKatie marked this conversation as resolved.
Outdated
WHERE degree > 20
RETURN n, degree ORDER BY degree DESC LIMIT 10

// Find disconnected components
MATCH (n)
WHERE NOT (n)--()
RETURN count(n) as isolated_nodes

// Identify potential duplicates
MATCH (n1), (n2)
WHERE id(n1) < id(n2)
AND n1.name = n2.name
AND n1.type = n2.type
RETURN n1, n2

// Find stale nodes (older than 30 days with no recent connections)
MATCH (n)
WHERE n.created_at < datetime() - duration({days: 30})
AND NOT (n)-[:UPDATED_AT|ACCESSED_AT]-()
Comment thread
SecKatie marked this conversation as resolved.
RETURN n LIMIT 20
\`\`\`

**Reorganization Operations:**
Implement the most impactful optimizations. Prioritize operations that provide the best balance of performance improvement and structural clarity.

Begin with analyzing the current graph structure and proceed with the reorganization plan.`

return {
messages: [
{
role: "user",
content: {
type: "text",
text: reorganizationMessage
}
}
]
}
}
)
}

export default function registerAllPrompts(server: McpServer): void {
registerUserSetupPrompt(server);
registerMemoryQueryPrompt(server);
registerGraphReorganizationPrompt(server);
}