feat(mcp): MCP server for AI clients, consuming the REST API
New app apps/mcp (NestJS + @nestjs-mcp/server 2): Streamable HTTP at POST /mcp, stateless. - 24 tools: projects (mine, public, details with settings, board, stats, analytics, activity), tickets (my work, search, details with comments and history, create, update, move, assign, release, comment, link), releases (list, upcoming, details with progress and burnup, create, publish) and users (whoami, search). Admin operations stay in the web. - No credentials of its own: each call's Authorization header (a Pireon token) is forwarded to the API; without it only public projects are read. - Typed REST client generated from apps/api/openapi.json (openapi-fetch + openapi-typescript via `nx run mcp:openapi-types`); API refusals become readable tool errors; parameters validated with zod. - Tests: the real MCP against a simulated API (token forwarding, errors, validation, writes). - Docker target `mcp` (Node 24) and an optional compose service under the `mcp` profile; zod declared as a root dependency. - Docs: chapter 9 «Servidor MCP», references in 01/06/07 and the index; Word/PDF regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
48
apps/mcp/src/app/app.module.ts
Normal file
48
apps/mcp/src/app/app.module.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { McpModule } from '@nestjs-mcp/server';
|
||||
import { TASKSTREAM_API_URL, TaskStreamApi } from './api/taskstream-api';
|
||||
import { HealthController } from './health.controller';
|
||||
import { IssuesResolver } from './tools/issues.resolver';
|
||||
import { ProjectsResolver } from './tools/projects.resolver';
|
||||
import { ReleasesResolver } from './tools/releases.resolver';
|
||||
import { UsersResolver } from './tools/users.resolver';
|
||||
|
||||
const INSTRUCTIONS = `TaskStream: issue tracker (projects, tickets, QA, releases).
|
||||
Projects and tickets go by key (WEB, WEB-12). Statuses, ticket types and areas are per
|
||||
project: read their ids with get_project before creating, updating or moving tickets, and
|
||||
use a ticket's allowedTransitions (get_issue) to move it. Tools act as the user whose Pireon
|
||||
token the client sends; without one, only public projects can be read.`;
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
McpModule.forRootAsync({
|
||||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) => ({
|
||||
name: 'taskstream',
|
||||
version: '1.0.0',
|
||||
instructions: INSTRUCTIONS,
|
||||
logging: { level: config.get('MCP_LOG_LEVEL', 'log') },
|
||||
}),
|
||||
}),
|
||||
],
|
||||
controllers: [HealthController],
|
||||
providers: [
|
||||
{
|
||||
provide: TASKSTREAM_API_URL,
|
||||
inject: [ConfigService],
|
||||
// Origin of the API (its routes already start with /api).
|
||||
useFactory: (config: ConfigService) =>
|
||||
config
|
||||
.get<string>('TASKSTREAM_API_URL', 'http://localhost:3000')
|
||||
.replace(/\/+$/, ''),
|
||||
},
|
||||
TaskStreamApi,
|
||||
ProjectsResolver,
|
||||
IssuesResolver,
|
||||
ReleasesResolver,
|
||||
UsersResolver,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
Reference in New Issue
Block a user