Skip to main content
Glama

NestJS MCP Server Module

by rekog-labs
MIT License
32,416
470
  • Apple
  • Linux
mcp.version.e2e.spec.ts1.88 kB
import { Controller, Get, INestApplication, VERSION_NEUTRAL, VersioningType, } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import request from 'supertest'; import { McpModule } from '../src/mcp/mcp.module'; import { SimpleTool } from './sample/simple.tool'; import { createSseClient } from './utils'; @Controller({ version: VERSION_NEUTRAL, }) class TestController { @Get() get() { return 'Hello World'; } } describe('E2E: MCP Version', () => { let app: INestApplication; let testPort: number; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [ McpModule.forRoot({ name: 'test-mcp-server', version: '0.0.1', guards: [], }), ], controllers: [TestController], providers: [SimpleTool], }).compile(); app = moduleFixture.createNestApplication(); // Enable versioning to test that our endpoints remain version neutral app.enableVersioning({ type: VersioningType.URI, defaultVersion: '1', }); await app.listen(0); const server = app.getHttpServer(); testPort = server.address().port; }); afterAll(async () => { await app.close(); }); it('should access SSE endpoint without version prefix', async () => { const client = await createSseClient(testPort); const tools = await client.listTools(); expect(tools.tools.length).toBe(1); await client.close(); }); it('should access test controller endpoint without version prefix', async () => { await request(app.getHttpServer()) .get('/') .expect(200) .expect('Hello World'); }); it('should not access test controller endpoint with version prefix', async () => { await request(app.getHttpServer()).get('/v1').expect(404); }); });

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/rekog-labs/MCP-Nest'

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