mirror of
https://github.com/samanhappy/mcphub.git
synced 2025-12-24 02:39:19 -05:00
refactor: update Dockerfile and package.json to add zod dependency; improve code formatting in server.ts
This commit is contained in:
@@ -3,9 +3,9 @@ FROM node:22-alpine
|
||||
|
||||
# Install Python and pip
|
||||
RUN apk add --no-cache \
|
||||
python3 \
|
||||
py3-pip \
|
||||
&& ln -sf python3 /usr/bin/python
|
||||
python3 \
|
||||
py3-pip \
|
||||
&& ln -sf python3 /usr/bin/python
|
||||
|
||||
# Create symbolic links for python commands
|
||||
RUN ln -sf /usr/bin/pip3 /usr/bin/pip
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.8.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2"
|
||||
"express": "^4.18.2",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -17,6 +17,9 @@ importers:
|
||||
express:
|
||||
specifier: ^4.18.2
|
||||
version: 4.21.2
|
||||
zod:
|
||||
specifier: ^3.24.2
|
||||
version: 3.24.2
|
||||
devDependencies:
|
||||
'@types/express':
|
||||
specifier: ^4.17.21
|
||||
|
||||
@@ -3,7 +3,8 @@ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
||||
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
||||
import { z, ZodType, ZodRawShape } from 'zod';
|
||||
import * as z from 'zod';
|
||||
import { ZodType, ZodRawShape } from 'zod';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@@ -31,7 +32,10 @@ function loadSettings(): McpSettings {
|
||||
}
|
||||
|
||||
// Initialize clients and transports from settings
|
||||
function initializeClientsFromSettings(): { clients: Client[]; transports: (SSEClientTransport | StdioClientTransport)[] } {
|
||||
function initializeClientsFromSettings(): {
|
||||
clients: Client[];
|
||||
transports: (SSEClientTransport | StdioClientTransport)[];
|
||||
} {
|
||||
const settings = loadSettings();
|
||||
const clients: Client[] = [];
|
||||
const transports: (SSEClientTransport | StdioClientTransport)[] = [];
|
||||
@@ -87,7 +91,7 @@ export const registerAllTools = async (server: McpServer) => {
|
||||
tool.name,
|
||||
tool.description || '',
|
||||
cast(tool.inputSchema.properties),
|
||||
async (params) => {
|
||||
async (params: Record<string, unknown>) => {
|
||||
console.log(`Calling tool: ${tool.name} with params: ${JSON.stringify(params)}`);
|
||||
const result = await client.callTool({
|
||||
name: tool.name,
|
||||
|
||||
Reference in New Issue
Block a user