feat(scenario): export/import endpoints and integration tests
- add GET /scenarios/:id/export returning ScenarioExportDto - add POST /scenarios/import creating scenario with all steps - add ScenarioExportDto and ScenarioStepExportDto classes - fix McpServer singleton by creating fresh instance per handle() call - add 12 integration tests covering shape, ordering, round-trip, validation
This commit is contained in:
+10
-8
@@ -15,8 +15,6 @@ import pkg from '../../package.json';
|
||||
|
||||
@Injectable()
|
||||
export class McpService {
|
||||
private readonly server: McpServer;
|
||||
|
||||
constructor(
|
||||
private readonly authService: AuthService,
|
||||
private readonly sessionService: SessionService,
|
||||
@@ -24,13 +22,15 @@ export class McpService {
|
||||
private readonly browserService: BrowserService,
|
||||
private readonly codeExecutor: CodeExecutorService,
|
||||
private readonly scenarioService: ScenarioService,
|
||||
) {
|
||||
this.server = new McpServer({ name: pkg.name, version: pkg.version });
|
||||
this.registerTools();
|
||||
) {}
|
||||
|
||||
private createServer(): McpServer {
|
||||
const server = new McpServer({ name: pkg.name, version: pkg.version });
|
||||
this.registerTools(server);
|
||||
return server;
|
||||
}
|
||||
|
||||
private registerTools(): void {
|
||||
const server = this.server;
|
||||
private registerTools(server: McpServer): void {
|
||||
|
||||
// ── Auth ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -454,12 +454,14 @@ export class McpService {
|
||||
}
|
||||
|
||||
async handle(req: Request, res: Response): Promise<void> {
|
||||
const server = this.createServer();
|
||||
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
||||
await this.server.connect(transport);
|
||||
await server.connect(transport);
|
||||
try {
|
||||
await transport.handleRequest(req, res, req.body);
|
||||
} finally {
|
||||
await transport.close();
|
||||
await server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user