mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-23 07:59:10 +00:00
simplify: unify 405 handlers, fix double-read in renameRundown, guard mcpClientConfig
- mcp.router.ts: extract identical GET/DELETE 405 responses into methodNotAllowed - mcp.service.ts: pass the already-patched rundown object to initRundown instead of re-fetching it from the data provider - McpSection.tsx: compute mcpClientConfig only when mcpEndpointUrl is truthy https://claude.ai/code/session_01U24MeuUacYXeQhbX3tatEe
This commit is contained in:
@@ -25,7 +25,9 @@ export default function McpSection() {
|
|||||||
});
|
});
|
||||||
}, [infoData]);
|
}, [infoData]);
|
||||||
|
|
||||||
const mcpClientConfig = JSON.stringify({ mcpServers: { ontime: { url: mcpEndpointUrl } } }, null, 2);
|
const mcpClientConfig = mcpEndpointUrl
|
||||||
|
? JSON.stringify({ mcpServers: { ontime: { url: mcpEndpointUrl } } }, null, 2)
|
||||||
|
: '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel.Section>
|
<Panel.Section>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||||
|
|
||||||
import express from 'express';
|
import express, { type Request, type Response } from 'express';
|
||||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||||
|
|
||||||
import { createMcpServer } from './mcp.server.js';
|
import { createMcpServer } from './mcp.server.js';
|
||||||
@@ -22,10 +22,8 @@ mcpRouter.post('/', async (req, res) => {
|
|||||||
|
|
||||||
// Stateless mode: GET (SSE) and DELETE (session teardown) are not applicable.
|
// Stateless mode: GET (SSE) and DELETE (session teardown) are not applicable.
|
||||||
// All MCP interactions happen via POST in a single request/response cycle.
|
// All MCP interactions happen via POST in a single request/response cycle.
|
||||||
mcpRouter.get('/', (_req, res) => {
|
const methodNotAllowed = (_req: Request, res: Response) =>
|
||||||
res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
|
void res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
|
||||||
});
|
|
||||||
|
|
||||||
mcpRouter.delete('/', (_req, res) => {
|
mcpRouter.get('/', methodNotAllowed);
|
||||||
res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
|
mcpRouter.delete('/', methodNotAllowed);
|
||||||
});
|
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ export async function renameRundown(id: string, title: string) {
|
|||||||
const dataProvider = getDataProvider();
|
const dataProvider = getDataProvider();
|
||||||
const rundown = dataProvider.getRundown(id);
|
const rundown = dataProvider.getRundown(id);
|
||||||
if (!rundown) throw new Error(`Rundown ${id} not found`);
|
if (!rundown) throw new Error(`Rundown ${id} not found`);
|
||||||
await dataProvider.setRundown(id, { ...rundown, title });
|
const updated = { ...rundown, title };
|
||||||
|
await dataProvider.setRundown(id, updated);
|
||||||
if (id === getCurrentRundown().id) {
|
if (id === getCurrentRundown().id) {
|
||||||
await initRundown(dataProvider.getRundown(id), dataProvider.getCustomFields());
|
await initRundown(updated, dataProvider.getCustomFields());
|
||||||
}
|
}
|
||||||
return rundownListResponse();
|
return rundownListResponse();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user