Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import {
Body,
Controller,
Delete,
Get,
HttpCode,
Logger,
Param,
Patch,
Post,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { McpService } from './mcp.service';
import { CreateMcpConfigDto } from './dto/create-mcp-config.dto';
import { UpdateMcpConfigDto } from './dto/update-mcp-config.dto';
import { BatchUpdateMcpToolsDto } from './dto/batch-update-mcp-tools.dto';
@ApiTags('mcp')
@Controller('mcp')
export class McpController {
private readonly logger = new Logger(McpController.name);
constructor(private readonly mcpService: McpService) {}
@Get('servers')
@ApiOperation({ summary: 'Get all MCP server configurations and status' })
@ApiResponse({
status: 200,
description: 'List of MCP servers with their tools and status',
})
getMcpServers() {
this.logger.log('Request received for GET /mcp/servers');
return this.mcpService.getMcpServers();
}
@Post('configs')
@HttpCode(201)
@ApiOperation({ summary: 'Create a new MCP server config' })
@ApiResponse({ status: 201, description: 'MCP server config created' })
@ApiResponse({ status: 400, description: 'Invalid JSON configuration' })
createMcpConfig(@Body() createMcpConfigDto: CreateMcpConfigDto) {
this.logger.log('Request received for POST /mcp/configs');
return this.mcpService.createMcpConfig(createMcpConfigDto.configJson);
}
@Patch('configs/:serverName')
@HttpCode(200)
@ApiOperation({ summary: 'Update MCP server active status' })
@ApiParam({ name: 'serverName', description: 'Name of the MCP server' })
@ApiResponse({ status: 200, description: 'MCP server status updated' })
@ApiResponse({ status: 404, description: 'MCP server not found' })
updateMcpConfigStatus(
@Param('serverName') serverName: string,
@Body() updateMcpConfigDto: UpdateMcpConfigDto,
) {
this.logger.log(`Request received for PATCH /mcp/configs/${serverName}`);
return this.mcpService.updateMcpConfigStatus(
serverName,
updateMcpConfigDto.is_active,
);
}
@Delete('configs/:serverName')
@HttpCode(204)
@ApiOperation({ summary: 'Delete an MCP server config' })
@ApiParam({ name: 'serverName', description: 'Name of the MCP server' })
@ApiResponse({ status: 204, description: 'MCP server config deleted' })
@ApiResponse({ status: 404, description: 'MCP server not found' })
deleteMcpConfig(@Param('serverName') serverName: string) {
this.logger.log(`Request received for DELETE /mcp/configs/${serverName}`);
return this.mcpService.deleteMcpConfig(serverName);
}
@Patch('tools')
@HttpCode(200)
@ApiOperation({ summary: 'Batch update tool activation status' })
@ApiResponse({ status: 200, description: 'Tools updated' })
batchUpdateToolStatus(@Body() batchUpdateDto: BatchUpdateMcpToolsDto) {
this.logger.log('Request received for PATCH /mcp/tools');
return this.mcpService.batchUpdateToolStatus(
batchUpdateDto.toolIds,
batchUpdateDto.is_active,
);
}
}
|