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:
Claude
2026-05-09 21:15:03 +00:00
committed by Carlos Valente
parent 65ef442a9d
commit ab15a65585
3 changed files with 11 additions and 10 deletions
@@ -25,7 +25,9 @@ export default function McpSection() {
});
}, [infoData]);
const mcpClientConfig = JSON.stringify({ mcpServers: { ontime: { url: mcpEndpointUrl } } }, null, 2);
const mcpClientConfig = mcpEndpointUrl
? JSON.stringify({ mcpServers: { ontime: { url: mcpEndpointUrl } } }, null, 2)
: '';
return (
<Panel.Section>
+5 -7
View File
@@ -1,6 +1,6 @@
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 { 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.
// All MCP interactions happen via POST in a single request/response cycle.
mcpRouter.get('/', (_req, res) => {
res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
});
const methodNotAllowed = (_req: Request, res: Response) =>
void res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
mcpRouter.delete('/', (_req, res) => {
res.status(405).json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
});
mcpRouter.get('/', methodNotAllowed);
mcpRouter.delete('/', methodNotAllowed);
+3 -2
View File
@@ -15,9 +15,10 @@ export async function renameRundown(id: string, title: string) {
const dataProvider = getDataProvider();
const rundown = dataProvider.getRundown(id);
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) {
await initRundown(dataProvider.getRundown(id), dataProvider.getCustomFields());
await initRundown(updated, dataProvider.getCustomFields());
}
return rundownListResponse();
}