Skip to content

Commit b19bf60

Browse files
olaservoshivdeepak
authored andcommitted
Standardize build and binary references
1 parent 6940a0d commit b19bf60

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

src/redis/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "@modelcontextprotocol/server-redis",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "MCP server for using Redis",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",
77
"homepage": "https://modelcontextprotocol.io",
88
"bugs": "https://github.com/modelcontextprotocol/servers/issues",
99
"type": "module",
1010
"bin": {
11-
"redis": "./build/index.js"
11+
"mcp-server-redis": "dist/index.js"
1212
},
1313
"files": [
14-
"build"
14+
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc && shx chmod +x build/*.js",
17+
"build": "tsc && shx chmod +x dist/*.js",
1818
"prepare": "npm run build",
1919
"watch": "tsc --watch"
2020
},

src/redis/src/index.ts

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
24
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
35
import {
@@ -233,26 +235,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
233235
}
234236
});
235237

236-
// Start the server
237-
async function main() {
238-
try {
239-
// Set up Redis event handlers
240-
redisClient.on('error', (err: Error) => {
241-
console.error('Redis Client Error:', err);
242-
});
238+
// Set up Redis event handlers
239+
redisClient.on('error', (err: Error) => {
240+
console.error('Redis Client Error:', err);
241+
});
243242

244-
redisClient.on('connect', () => {
245-
console.error(`Connected to Redis at ${REDIS_URL}`);
246-
});
243+
redisClient.on('connect', () => {
244+
console.error(`Connected to Redis at ${REDIS_URL}`);
245+
});
247246

248-
redisClient.on('reconnecting', () => {
249-
console.error('Attempting to reconnect to Redis...');
250-
});
247+
redisClient.on('reconnecting', () => {
248+
console.error('Attempting to reconnect to Redis...');
249+
});
251250

252-
redisClient.on('end', () => {
253-
console.error('Redis connection closed');
254-
});
251+
redisClient.on('end', () => {
252+
console.error('Redis connection closed');
253+
});
255254

255+
async function runServer() {
256+
try {
256257
// Connect to Redis
257258
await redisClient.connect();
258259

@@ -261,26 +262,21 @@ async function main() {
261262
await server.connect(transport);
262263
console.error("Redis MCP Server running on stdio");
263264
} catch (error) {
264-
console.error("Error during startup:", error);
265-
await cleanup();
265+
console.error("Fatal error running server:", error);
266+
await redisClient.quit().catch(() => {});
267+
process.exit(1);
266268
}
267269
}
268270

269-
// Cleanup function
270-
async function cleanup() {
271-
try {
272-
await redisClient.quit();
273-
} catch (error) {
274-
console.error("Error during cleanup:", error);
275-
}
276-
process.exit(1);
277-
}
278-
279271
// Handle process termination
280-
process.on('SIGINT', cleanup);
281-
process.on('SIGTERM', cleanup);
272+
process.on('SIGINT', async () => {
273+
await redisClient.quit().catch(() => {});
274+
process.exit(0);
275+
});
282276

283-
main().catch((error) => {
284-
console.error("Fatal error in main():", error);
285-
cleanup();
277+
process.on('SIGTERM', async () => {
278+
await redisClient.quit().catch(() => {});
279+
process.exit(0);
286280
});
281+
282+
runServer();

src/redis/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "ES2022",
44
"module": "Node16",
55
"moduleResolution": "Node16",
6-
"outDir": "./build",
6+
"outDir": "./dist",
77
"rootDir": "./src",
88
"strict": true,
99
"esModuleInterop": true,
@@ -13,4 +13,3 @@
1313
"include": ["src/**/*"],
1414
"exclude": ["node_modules"]
1515
}
16-

0 commit comments

Comments
 (0)