@mushi-mushi/mcp 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { McpScope } from './catalog.js';
3
+
4
+ /**
5
+ * FILE: packages/mcp/src/server.ts
6
+ * PURPOSE: Testable MCP server factory. Exports `createMushiServer()` which
7
+ * builds a fully-configured `McpServer` but does not connect to any
8
+ * transport — allowing the stdio entry (`src/index.ts`) and the
9
+ * in-memory integration tests to share the exact same tool
10
+ * implementations. Keeping the module side-effect-free is critical:
11
+ * the old design called `main()` at import time, which made it
12
+ * impossible to mock `fetch` before the server had wired up its
13
+ * closures.
14
+ *
15
+ * Every tool/resource is a thin, typed wrapper over the Mushi REST
16
+ * API; auth is an API key sent in two headers so the shared
17
+ * `adminOrApiKey` middleware accepts it regardless of which header
18
+ * a proxy strips first.
19
+ */
20
+
21
+ declare class MushiApiError extends Error {
22
+ readonly status: number;
23
+ readonly code: string;
24
+ constructor(status: number, code: string, message: string);
25
+ }
26
+ interface MushiServerConfig {
27
+ /** Server version — surfaced in MCP handshake. Read from package.json by boot. */
28
+ version: string;
29
+ /** Base URL of the Mushi API, e.g. https://xyz.supabase.co/functions/v1/api */
30
+ apiEndpoint: string;
31
+ /** Project API key with `mcp:read` or `mcp:write` scope. */
32
+ apiKey: string;
33
+ /** Optional project hint. Used to scope multi-project tools. */
34
+ projectId?: string;
35
+ /**
36
+ * Granted scopes from the API key. When provided, only tools/resources that
37
+ * require a subset of these scopes are registered. Defaults to ALL_SCOPES.
38
+ */
39
+ scopes?: readonly McpScope[];
40
+ /**
41
+ * Fetch implementation — overridable for tests. Tests pass a spy that
42
+ * asserts request shape and returns canned envelopes without hitting the
43
+ * network. Defaults to the global `fetch`.
44
+ */
45
+ fetch?: typeof fetch;
46
+ }
47
+ /**
48
+ * Build an MCP server instance pre-wired with every Mushi tool, resource,
49
+ * and prompt. Does NOT call `server.connect()` — the caller binds whatever
50
+ * transport they need (stdio for the CLI, InMemoryTransport for tests).
51
+ */
52
+ declare function createMushiServer(config: MushiServerConfig): McpServer;
53
+
54
+ export { MushiApiError, type MushiServerConfig, createMushiServer };