Standardize build and binary references
This commit is contained in:
parent
c19925b8f0
commit
e5477c2bd4
3 changed files with 34 additions and 39 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@modelcontextprotocol/server-redis",
|
"name": "@modelcontextprotocol/server-redis",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "MCP server for using Redis",
|
"description": "MCP server for using Redis",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Anthropic, PBC (https://anthropic.com)",
|
"author": "Anthropic, PBC (https://anthropic.com)",
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
"bugs": "https://github.com/modelcontextprotocol/servers/issues",
|
"bugs": "https://github.com/modelcontextprotocol/servers/issues",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
"redis": "./build/index.js"
|
"mcp-server-redis": "dist/index.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"build"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && shx chmod +x build/*.js",
|
"build": "tsc && shx chmod +x dist/*.js",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
"watch": "tsc --watch"
|
"watch": "tsc --watch"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
import {
|
import {
|
||||||
|
|
@ -233,26 +235,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start the server
|
// Set up Redis event handlers
|
||||||
async function main() {
|
redisClient.on('error', (err: Error) => {
|
||||||
|
console.error('Redis Client Error:', err);
|
||||||
|
});
|
||||||
|
|
||||||
|
redisClient.on('connect', () => {
|
||||||
|
console.error(`Connected to Redis at ${REDIS_URL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
redisClient.on('reconnecting', () => {
|
||||||
|
console.error('Attempting to reconnect to Redis...');
|
||||||
|
});
|
||||||
|
|
||||||
|
redisClient.on('end', () => {
|
||||||
|
console.error('Redis connection closed');
|
||||||
|
});
|
||||||
|
|
||||||
|
async function runServer() {
|
||||||
try {
|
try {
|
||||||
// Set up Redis event handlers
|
|
||||||
redisClient.on('error', (err: Error) => {
|
|
||||||
console.error('Redis Client Error:', err);
|
|
||||||
});
|
|
||||||
|
|
||||||
redisClient.on('connect', () => {
|
|
||||||
console.error(`Connected to Redis at ${REDIS_URL}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
redisClient.on('reconnecting', () => {
|
|
||||||
console.error('Attempting to reconnect to Redis...');
|
|
||||||
});
|
|
||||||
|
|
||||||
redisClient.on('end', () => {
|
|
||||||
console.error('Redis connection closed');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Connect to Redis
|
// Connect to Redis
|
||||||
await redisClient.connect();
|
await redisClient.connect();
|
||||||
|
|
||||||
|
|
@ -261,26 +262,21 @@ async function main() {
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
console.error("Redis MCP Server running on stdio");
|
console.error("Redis MCP Server running on stdio");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during startup:", error);
|
console.error("Fatal error running server:", error);
|
||||||
await cleanup();
|
await redisClient.quit().catch(() => {});
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup function
|
|
||||||
async function cleanup() {
|
|
||||||
try {
|
|
||||||
await redisClient.quit();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error during cleanup:", error);
|
|
||||||
}
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle process termination
|
// Handle process termination
|
||||||
process.on('SIGINT', cleanup);
|
process.on('SIGINT', async () => {
|
||||||
process.on('SIGTERM', cleanup);
|
await redisClient.quit().catch(() => {});
|
||||||
|
process.exit(0);
|
||||||
main().catch((error) => {
|
|
||||||
console.error("Fatal error in main():", error);
|
|
||||||
cleanup();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', async () => {
|
||||||
|
await redisClient.quit().catch(() => {});
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
runServer();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "Node16",
|
"module": "Node16",
|
||||||
"moduleResolution": "Node16",
|
"moduleResolution": "Node16",
|
||||||
"outDir": "./build",
|
"outDir": "./dist",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|
@ -13,4 +13,3 @@
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue