integration-mcp-server
Version:
Integration MCP Server with YouTrack, Forgejo, and language server capabilities - easy setup for Claude Desktop & VSCode with Windows compatibility
143 lines • 5.04 kB
JavaScript
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
// 환경 변수 로드
import dotenv from 'dotenv';
dotenv.config();
const server = new Server({
name: 'integration-mcp-server',
version: '1.2.4',
}, {
capabilities: {
tools: {}
}
});
// List available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: 'echo',
description: 'Echo back the provided text',
inputSchema: {
type: 'object',
properties: {
text: {
type: 'string',
description: 'Text to echo back',
},
},
required: ['text'],
},
},
{
name: 'get_time',
description: 'Get the current time',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'analyze_project',
description: 'Analyze the current project structure',
inputSchema: {
type: 'object',
properties: {
path: {
type: 'string',
description: 'Path to analyze (defaults to current directory)',
},
},
},
},
],
};
});
// Handle tool calls
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
switch (name) {
case 'echo':
if (!args || typeof args.text !== 'string') {
throw new McpError(ErrorCode.InvalidParams, 'text parameter is required');
}
return {
content: [
{
type: 'text',
text: `Echo: ${args.text}`,
},
],
};
case 'get_time':
return {
content: [
{
type: 'text',
text: `Current time: ${new Date().toISOString()}`,
},
],
};
case 'analyze_project':
const fs = await import('fs');
const path = await import('path');
const targetPath = (args && typeof args.path === 'string') ? args.path : process.cwd();
try {
const files = fs.readdirSync(targetPath);
const analysis = {
path: targetPath,
totalFiles: files.length,
directories: files.filter(f => {
try {
return fs.statSync(path.join(targetPath, f)).isDirectory();
}
catch {
return false;
}
}),
files: files.filter(f => {
try {
return fs.statSync(path.join(targetPath, f)).isFile();
}
catch {
return false;
}
}),
};
return {
content: [
{
type: 'text',
text: JSON.stringify(analysis, null, 2),
},
],
};
}
catch (error) {
throw new McpError(ErrorCode.InternalError, `Failed to analyze project: ${error}`);
}
default:
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
}
}
catch (error) {
if (error instanceof McpError) {
throw error;
}
throw new McpError(ErrorCode.InternalError, `Tool execution failed: ${error}`);
}
});
// Start the server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('Integration MCP Server running on stdio');
}
main().catch((error) => {
console.error('Server failed to start:', error);
process.exit(1);
});
//# sourceMappingURL=index.js.map