/**
* Microsoft Sentinel Solutions Analyzer MCP Server
* Analyzes Microsoft Sentinel solutions and maps data connectors to Log Analytics tables
*/
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { allTools } from './tools/index.js';
// Create MCP server
const server = new Server(
{
name: 'sentinel-analyzer',
version: '1.0.0',
},
{
capabilities: {
tools: {},
},
}
);
// Handle list_tools request
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: allTools.map((tool) => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema,
})),
};
});
// Handle call_tool request
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
const tool = allTools.find((t) => t.name === name);
if (!tool) {
throw new Error(`Unknown tool: ${name}`);
}
try {
// Validate arguments
const validatedArgs = tool.inputSchema.parse(args || {});
// Execute tool
const result = await tool.execute(validatedArgs as any);
return {
content: [
{
type: 'text',
text: JSON.stringify(result, null, 2),
},
],
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
content: [
{
type: 'text',
text: JSON.stringify(
{
error: errorMessage,
tool: name,
},
null,
2
),
},
],
isError: true,
};
}
});
// Start server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('Microsoft Sentinel Solutions Analyzer MCP Server started');
console.error('Available tools:', allTools.map((t) => t.name).join(', '));
}
main().catch((error) => {
console.error('Fatal error:', error);
process.exit(1);
});