Skip to main content
Glama

π“‚€π“’π“‹Ήπ”Έβ„•π•Œπ”Ήπ•€π•Šπ“‹Ήπ“’π“‚€ - Intelligent Guidance for

by Hive-Academy
app.module.tsβ€’3.56 kB
import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { APP_FILTER } from '@nestjs/core'; import { McpModule, McpTransportType } from '@rekog/mcp-nest'; import { PrismaModule } from './prisma/prisma.module'; import { UtilsModule } from './utils/utils.module'; // Global exception filter for MCP debugging import { ArgumentsHost, Catch, ExceptionFilter, HttpException, Logger, } from '@nestjs/common'; import { InitRulesModule } from './domains/init-rules/init-rules.module'; import { TaskManagementModule } from './domains/task-management/task-management.module'; import { WorkflowContextValidationGuard } from './domains/workflow-rules/guards/workflow-context-validation.guard'; import { WorkflowRulesModule } from './domains/workflow-rules/workflow-rules.module'; // Determine transport type based on environment const getTransportType = (): McpTransportType => { const transportEnv = process.env.MCP_TRANSPORT_TYPE?.toUpperCase(); switch (transportEnv) { case 'HTTP': case 'SSE': return McpTransportType.SSE; case 'STREAMABLE_HTTP': return McpTransportType.STREAMABLE_HTTP; case 'STDIO': default: return McpTransportType.STDIO; } }; @Catch() export class GlobalExceptionFilter implements ExceptionFilter { private readonly logger = new Logger(GlobalExceptionFilter.name); catch(exception: unknown, host: ArgumentsHost) { const timestamp = new Date().toISOString(); // Log the exception with full details this.logger.error('[MCP-GLOBAL-EXCEPTION]', { timestamp, exception: exception instanceof Error ? { name: exception.name, message: exception.message, stack: exception.stack, } : exception, hostType: host.getType(), context: 'MCP Tool Call Handler', }); // If it's an HTTP exception, rethrow it if (exception instanceof HttpException) { throw exception; } // For other exceptions, create a generic error response throw new Error( `Unhandled exception in MCP handler: ${exception instanceof Error ? exception.message : 'Unknown error'}`, ); } } @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, // Ensure environment variables are available expandVariables: true, }), PrismaModule, McpModule.forRoot({ name: process.env.MCP_SERVER_NAME || 'Anubis', version: process.env.MCP_SERVER_VERSION || '1.0.0', instructions: '🏺 Anubis - Intelligent Guidance for AI Workflows | MCP-compliant workflow intelligence system with embedded, context-aware guidance for reliable AI-assisted development', transport: getTransportType(), // Additional configuration for HTTP/SSE transports ...(getTransportType() === McpTransportType.SSE && { sseEndpoint: 'sse', messagesEndpoint: 'messages', }), ...(getTransportType() === McpTransportType.STREAMABLE_HTTP && { mcpEndpoint: 'mcp', }), guards: [WorkflowContextValidationGuard], }), // Rule-based workflow architecture - clean and focused TaskManagementModule, // Internal task management services (NOT MCP tools) WorkflowRulesModule, // Rule-driven workflow MCP interface (8 tools) InitRulesModule, // Tool initialization for different AI agents, UtilsModule, ], providers: [ { provide: APP_FILTER, useClass: GlobalExceptionFilter, }, ], }) export class AppModule {}

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hive-Academy/Anubis-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server