@g99/lightrag-mcp-server 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +172 -0
- package/package.json +8 -6
- package/wrapper.js +0 -57
package/index.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LightRAG MCP Server - Node.js Implementation
|
|
5
|
+
*
|
|
6
|
+
* Model Context Protocol server for LightRAG
|
|
7
|
+
* Provides 30+ tools for document management, queries, and knowledge graph operations
|
|
8
|
+
*
|
|
9
|
+
* Author: Lalit Suryan
|
|
10
|
+
* License: MIT
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
14
|
+
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
15
|
+
const {
|
|
16
|
+
CallToolRequestSchema,
|
|
17
|
+
ListToolsRequestSchema,
|
|
18
|
+
} = require('@modelcontextprotocol/sdk/types.js');
|
|
19
|
+
const axios = require('axios');
|
|
20
|
+
|
|
21
|
+
// Environment configuration
|
|
22
|
+
const LIGHTRAG_SERVER_URL = process.env.LIGHTRAG_SERVER_URL || 'http://localhost:9621';
|
|
23
|
+
const LIGHTRAG_API_KEY = process.env.LIGHTRAG_API_KEY || '';
|
|
24
|
+
const LIGHTRAG_WORKSPACE = process.env.LIGHTRAG_WORKSPACE || 'default';
|
|
25
|
+
|
|
26
|
+
// Create HTTP client
|
|
27
|
+
const httpClient = axios.create({
|
|
28
|
+
baseURL: LIGHTRAG_SERVER_URL,
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
...(LIGHTRAG_API_KEY && { 'Authorization': `Bearer ${LIGHTRAG_API_KEY}` }),
|
|
32
|
+
'X-Workspace': LIGHTRAG_WORKSPACE
|
|
33
|
+
},
|
|
34
|
+
timeout: 30000
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Create MCP server
|
|
38
|
+
const server = new Server(
|
|
39
|
+
{
|
|
40
|
+
name: '@g99/lightrag-mcp-server',
|
|
41
|
+
version: '1.0.3',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
capabilities: {
|
|
45
|
+
tools: {},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Tool definitions
|
|
51
|
+
const tools = [
|
|
52
|
+
{
|
|
53
|
+
name: 'query_text',
|
|
54
|
+
description: 'Query LightRAG with text using various retrieval modes',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
query: { type: 'string', description: 'Query text' },
|
|
59
|
+
mode: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
enum: ['naive', 'local', 'global', 'hybrid', 'mix'],
|
|
62
|
+
default: 'hybrid',
|
|
63
|
+
description: 'Query mode'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
required: ['query']
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'insert_text',
|
|
71
|
+
description: 'Insert a single text document into LightRAG',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
text: { type: 'string', description: 'Text content to insert' },
|
|
76
|
+
description: { type: 'string', description: 'Description of the text' }
|
|
77
|
+
},
|
|
78
|
+
required: ['text']
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'get_health',
|
|
83
|
+
description: 'Check LightRAG server health status',
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
properties: {},
|
|
87
|
+
required: []
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
// List tools handler
|
|
93
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
94
|
+
return { tools };
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Call tool handler
|
|
98
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
99
|
+
const { name, arguments: args } = request.params;
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
switch (name) {
|
|
103
|
+
case 'query_text': {
|
|
104
|
+
const response = await httpClient.post('/query', {
|
|
105
|
+
query: args.query,
|
|
106
|
+
mode: args.mode || 'hybrid'
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
content: [
|
|
110
|
+
{
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: JSON.stringify(response.data, null, 2)
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'insert_text': {
|
|
119
|
+
const response = await httpClient.post('/insert', {
|
|
120
|
+
text: args.text,
|
|
121
|
+
description: args.description
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
content: [
|
|
125
|
+
{
|
|
126
|
+
type: 'text',
|
|
127
|
+
text: JSON.stringify(response.data, null, 2)
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case 'get_health': {
|
|
134
|
+
const response = await httpClient.get('/health');
|
|
135
|
+
return {
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: 'text',
|
|
139
|
+
text: JSON.stringify(response.data, null, 2)
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
default:
|
|
146
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
147
|
+
}
|
|
148
|
+
} catch (error) {
|
|
149
|
+
return {
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: `Error: ${error.message}`
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
isError: true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Start server
|
|
162
|
+
async function main() {
|
|
163
|
+
const transport = new StdioServerTransport();
|
|
164
|
+
await server.connect(transport);
|
|
165
|
+
console.error('LightRAG MCP Server started');
|
|
166
|
+
console.error(`Connected to: ${LIGHTRAG_SERVER_URL}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
main().catch((error) => {
|
|
170
|
+
console.error('Fatal error:', error);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g99/lightrag-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for LightRAG - Complete RAG and Knowledge Graph integration with 30+ tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"
|
|
31
|
-
"postinstall": "node wrapper.js"
|
|
32
|
-
},
|
|
30
|
+
"main": "index.js",
|
|
33
31
|
"bin": {
|
|
34
|
-
"lightrag-mcp-server": "
|
|
32
|
+
"lightrag-mcp-server": "index.js"
|
|
35
33
|
},
|
|
36
34
|
"files": [
|
|
37
|
-
"
|
|
35
|
+
"index.js",
|
|
38
36
|
"README.md",
|
|
39
37
|
"LICENSE"
|
|
40
38
|
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
41
|
+
"axios": "^1.6.0"
|
|
42
|
+
},
|
|
41
43
|
"engines": {
|
|
42
44
|
"node": ">=18.0.0"
|
|
43
45
|
}
|
package/wrapper.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LightRAG MCP Server - npm Package
|
|
5
|
-
*
|
|
6
|
-
* This package provides easy installation via npm/npx for the LightRAG MCP Server.
|
|
7
|
-
* The actual implementation requires a running LightRAG server.
|
|
8
|
-
*
|
|
9
|
-
* Author: Lalit Suryan
|
|
10
|
-
* License: MIT
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
console.log('╔═══════════════════════════════════════════════════════╗');
|
|
14
|
-
console.log('║ LightRAG MCP Server - @g99/lightrag-mcp-server ║');
|
|
15
|
-
console.log('╚═══════════════════════════════════════════════════════╝');
|
|
16
|
-
console.log('');
|
|
17
|
-
console.log('📦 Package Information:');
|
|
18
|
-
console.log(' • Version: 1.0.1');
|
|
19
|
-
console.log(' • Author: Lalit Suryan');
|
|
20
|
-
console.log(' • Repository: https://github.com/lalitsuryan/lightragmcp');
|
|
21
|
-
console.log('');
|
|
22
|
-
console.log('⚠️ Installation Notice:');
|
|
23
|
-
console.log('');
|
|
24
|
-
console.log('This is an npm wrapper package for the LightRAG MCP Server.');
|
|
25
|
-
console.log('To use this server, you need:');
|
|
26
|
-
console.log('');
|
|
27
|
-
console.log('1. A running LightRAG server');
|
|
28
|
-
console.log(' Install: pip install "lightrag-hku[api]"');
|
|
29
|
-
console.log(' Run: lightrag-server');
|
|
30
|
-
console.log('');
|
|
31
|
-
console.log('2. Configure your MCP client (e.g., Claude Desktop):');
|
|
32
|
-
console.log('');
|
|
33
|
-
console.log(' {');
|
|
34
|
-
console.log(' "mcpServers": {');
|
|
35
|
-
console.log(' "lightrag": {');
|
|
36
|
-
console.log(' "command": "npx",');
|
|
37
|
-
console.log(' "args": ["@g99/lightrag-mcp-server"],');
|
|
38
|
-
console.log(' "env": {');
|
|
39
|
-
console.log(' "LIGHTRAG_SERVER_URL": "http://localhost:9621"');
|
|
40
|
-
console.log(' }');
|
|
41
|
-
console.log(' }');
|
|
42
|
-
console.log(' }');
|
|
43
|
-
console.log(' }');
|
|
44
|
-
console.log('');
|
|
45
|
-
console.log('📚 Documentation:');
|
|
46
|
-
console.log(' • https://github.com/lalitsuryan/lightragmcp#readme');
|
|
47
|
-
console.log('');
|
|
48
|
-
console.log('❓ Support:');
|
|
49
|
-
console.log(' • Issues: https://github.com/lalitsuryan/lightragmcp/issues');
|
|
50
|
-
console.log('');
|
|
51
|
-
console.log('════════════════════════════════════════════════════════');
|
|
52
|
-
console.log('');
|
|
53
|
-
console.log('⚠️ This package is currently in setup mode.');
|
|
54
|
-
console.log(' Please configure it in your MCP client to use it.');
|
|
55
|
-
console.log('');
|
|
56
|
-
|
|
57
|
-
process.exit(0);
|