mcp-extended-tools
Version:
Extended tools for command execution
77 lines (71 loc) • 2.32 kB
JavaScript
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';
import { executor } from '../index.js';
import { fileManager } from './file-manager.js';
// Minimal logging function
function log(message) {
console.error(`[MCP Extended Tools] ${message}`);
}
// Explicitly define a clear schema for method handling
const RequestSchema = z.object({
jsonrpc: z.literal('2.0'),
method: z.string(),
params: z.any().optional(),
id: z.union([z.string(), z.number()]).optional()
});
const server = new Server(
{
name: "mcp-extended-tools",
version: "1.8.4"
},
{
capabilities: {
"tools/execute_command": {
description: "Execute a command in the terminal",
parameters: {
type: "object",
properties: {
command: { type: "string" }
},
required: ["command"]
}
},
"files/read": {
description: "Read the contents of a file",
parameters: {
type: "object",
properties: {
path: { type: "string" }
},
required: ["path"]
}
},
"files/write": {
description: "Write content to a file",
parameters: {
type: "object",
properties: {
path: { type: "string" },
content: { type: "string" }
},
required: ["path", "content"]
}
},
"files/list": {
description: "List files and directories in a path",
parameters: {
type: "object",
properties: {
path: { type: "string" }
},
required: ["path"]
}
}
}
}
);
// Rest of the file remains the same as in the previous version.
// ... (full content of the previous index.js)
start();