-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
33 lines (29 loc) · 1.23 KB
/
Copy pathserver.ts
File metadata and controls
33 lines (29 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { TenantContext } from "./auth.js";
import { HospitableClient } from "./hospitable/client.js";
import { HospitableInternalClient } from "./hospitable/internal-client.js";
import { registerAllTools } from "./tools/register.js";
import { registerInternalTools } from "./tools/internal.js";
export function createMcpServer(ctx: TenantContext): McpServer {
const server = new McpServer(
{ name: "hospitable-mcp", version: "0.1.0" },
{ capabilities: { tools: {} } }
);
const client = new HospitableClient(ctx.pat);
registerAllTools(server, client, ctx);
// Internal-API tools (operator's Hospitable account, not the tenant's PAT).
// Only registered when an operator JWT is configured on the server.
const internalJwt = process.env.HOSPITABLE_INTERNAL_JWT?.trim();
if (internalJwt) {
try {
const internalClient = new HospitableInternalClient(internalJwt);
registerInternalTools(server, internalClient, ctx);
} catch (err) {
console.error(
"[hospitable-mcp] HOSPITABLE_INTERNAL_JWT is set but invalid — internal tools disabled:",
err instanceof Error ? err.message : err
);
}
}
return server;
}