@@ -53,11 +53,17 @@ export const createSseRouter = ({
|
||||
|
||||
router.post('/messages', async (req, res) => {
|
||||
const sessionId = req.query.sessionId as string;
|
||||
|
||||
if (!sessionId) {
|
||||
res.status(400).send('sessionId is required');
|
||||
return;
|
||||
}
|
||||
|
||||
const transport = transportsToSessionId.get(sessionId);
|
||||
if (transport) {
|
||||
await transport.handlePostMessage(req, res, req.body);
|
||||
} else {
|
||||
res.status(400).send('No transport found for sessionId');
|
||||
res.status(400).send(`No transport found for sessionId "${sessionId}"`);
|
||||
}
|
||||
});
|
||||
return router;
|
||||
|
||||
@@ -188,6 +188,6 @@ describe('McpService', () => {
|
||||
},
|
||||
CallToolResultSchema,
|
||||
),
|
||||
).rejects.toThrow('Action mock-action not found');
|
||||
).rejects.toThrow('Action "mock-action" not found');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { ActionsService } from '@backstage/backend-plugin-api/alpha';
|
||||
import { version } from '@backstage/plugin-mcp-actions-backend/package.json';
|
||||
import { NotFoundError } from '@backstage/errors';
|
||||
|
||||
export class McpService {
|
||||
constructor(private readonly actions: ActionsService) {}
|
||||
@@ -65,7 +66,7 @@ export class McpService {
|
||||
const action = actions.find(a => a.name === params.name);
|
||||
|
||||
if (!action) {
|
||||
throw new Error(`Action ${params.name} not found`);
|
||||
throw new NotFoundError(`Action "${params.name}" not found`);
|
||||
}
|
||||
|
||||
const { output } = await this.actions.invoke({
|
||||
|
||||
Reference in New Issue
Block a user