@cubicecho/server-kit 0.5.1 → 0.6.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.
- package/_agents/docs/06-http.md +1 -0
- package/_agents/docs/07-mcp.md +32 -0
- package/dist/http/auth-redirects.js +1 -15
- package/dist/http/headers.d.ts +8 -0
- package/dist/http/headers.js +15 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/mcp/defaults.d.ts +11 -0
- package/dist/mcp/defaults.js +7 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/request.d.ts +9 -0
- package/dist/mcp/request.js +20 -0
- package/dist/mcp/tool-options.d.ts +19 -0
- package/dist/mcp/tool-options.js +41 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/index.js +13 -0
- package/dist/testing/mcp-problems.d.ts +14 -0
- package/dist/testing/mcp-problems.js +23 -0
- package/llms.txt +15 -1
- package/package.json +11 -1
package/_agents/docs/06-http.md
CHANGED
|
@@ -28,3 +28,4 @@ stopOnSignals(server, { before: () => scheduler.stop(), after: closeDatabase });
|
|
|
28
28
|
- `createStaticHandler` keeps `/assets/` and `/_expo/` files for a year, and answers 404 for one that is gone. Anything else that is not a file is `index.html`.
|
|
29
29
|
- `stopOnSignals` drains, runs `after`, and exits within `shutdownDeadlineSeconds`, under Docker's 10. A second signal exits at once.
|
|
30
30
|
- `oidcSignInUrl` and `oidcRedirectUri` name the two OIDC routes for a provider.
|
|
31
|
+
- `toHeaders` copies Node's headers into fetch `Headers`, for a door that reads its own caller.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# MCP
|
|
2
|
+
|
|
3
|
+
`@cubicecho/server-kit/mcp` has what every MCP door over a drizzle-graphql schema shares: how the caller is read, and the options that keep the listing small. It needs `@cubicecho/graphql-mcp`, an optional peer.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createHttpHandler } from '@cubicecho/graphql-mcp';
|
|
7
|
+
import { HTTP_DEFAULTS } from '@cubicecho/server-kit/http';
|
|
8
|
+
import { contextFromRequest, toolOptions } from '@cubicecho/server-kit/mcp';
|
|
9
|
+
import express from 'express';
|
|
10
|
+
|
|
11
|
+
const mcp = createHttpHandler({
|
|
12
|
+
...toolOptions({ hints: { tasks: 'Every task. Run one with `run_task`.' } }),
|
|
13
|
+
schema,
|
|
14
|
+
name: 'my-service',
|
|
15
|
+
version: version(),
|
|
16
|
+
contextFromRequest: contextFromRequest(contextFor),
|
|
17
|
+
include: TOOLS,
|
|
18
|
+
});
|
|
19
|
+
app.all('/mcp', express.json({ limit: HTTP_DEFAULTS.bodyLimit }), mcp);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { checkMcpBudget } from '@cubicecho/server-kit/testing';
|
|
24
|
+
|
|
25
|
+
checkMcpBudget(async () => (await client.listTools()).tools);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Serve the permissioned schema. `include` says what an agent is told about, and only permissions say what it can reach.
|
|
29
|
+
- `contextFromRequest` takes the context factory /graphql uses, so a key or a session means the same on both doors.
|
|
30
|
+
- `toolOptions` selects one level, allows an explicit null on writes only, drops filters and orders on other tables, and reads read-only and destructive hints from the create, update and delete prefixes. An option written after the spread replaces it.
|
|
31
|
+
- `hints` are keyed by the MCP name (`create_task`), and `include` by the field (`Mutation.createTask`).
|
|
32
|
+
- `checkMcpBudget` holds one tool to `MCP_DEFAULTS.maxToolSchemaChars` and the listing to `maxToolListChars`. List through a real client, as an agent would.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AUTH_PATHS } from '../auth/defaults.js';
|
|
2
|
+
import { toHeaders } from './headers.js';
|
|
2
3
|
import { HttpStatus } from './status.js';
|
|
3
4
|
/** better-auth's routes, where Express hands them over. */
|
|
4
5
|
const AUTH_BASE_PATH = '/api/auth';
|
|
@@ -41,21 +42,6 @@ export function mountAuthRedirects(app, options) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Copies Express's headers into fetch `Headers`, which better-auth reads cookies from.
|
|
46
|
-
*
|
|
47
|
-
* @param raw - The request's headers as Node parsed them.
|
|
48
|
-
* @returns The same headers, repeated ones appended.
|
|
49
|
-
*/
|
|
50
|
-
function toHeaders(raw) {
|
|
51
|
-
const headers = new Headers();
|
|
52
|
-
for (const [name, value] of Object.entries(raw)) {
|
|
53
|
-
for (const one of [value ?? []].flat()) {
|
|
54
|
-
headers.append(name, one);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return headers;
|
|
58
|
-
}
|
|
59
45
|
/**
|
|
60
46
|
* Hands a browser request to better-auth, and carries its redirect back.
|
|
61
47
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Copies Node's headers into fetch `Headers`, which better-auth reads the caller from.
|
|
4
|
+
*
|
|
5
|
+
* @param raw - A request's headers as Node parsed them.
|
|
6
|
+
* @returns The same headers, repeated ones appended.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toHeaders(raw: IncomingHttpHeaders): Headers;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies Node's headers into fetch `Headers`, which better-auth reads the caller from.
|
|
3
|
+
*
|
|
4
|
+
* @param raw - A request's headers as Node parsed them.
|
|
5
|
+
* @returns The same headers, repeated ones appended.
|
|
6
|
+
*/
|
|
7
|
+
export function toHeaders(raw) {
|
|
8
|
+
const headers = new Headers();
|
|
9
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
10
|
+
for (const one of [value ?? []].flat()) {
|
|
11
|
+
headers.append(name, one);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return headers;
|
|
15
|
+
}
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type AuthRedirectOptions, mountAuthRedirects, oidcRedirectUri, oidcSignInUrl } from './auth-redirects.ts';
|
|
2
2
|
export { HTTP_DEFAULTS, type HttpSettings } from './defaults.ts';
|
|
3
|
+
export { toHeaders } from './headers.ts';
|
|
3
4
|
export { checkHealth, type Health } from './health.ts';
|
|
4
5
|
export { drain, type ShutdownSteps, stopOnSignals } from './shutdown.ts';
|
|
5
6
|
export { createStaticHandler, type StaticHandler } from './static.ts';
|
package/dist/http/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { mountAuthRedirects, oidcRedirectUri, oidcSignInUrl } from './auth-redirects.js';
|
|
2
2
|
export { HTTP_DEFAULTS } from './defaults.js';
|
|
3
|
+
export { toHeaders } from './headers.js';
|
|
3
4
|
export { checkHealth } from './health.js';
|
|
4
5
|
export { drain, stopOnSignals } from './shutdown.js';
|
|
5
6
|
export { createStaticHandler } from './static.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Bounds on the MCP door. */
|
|
2
|
+
export interface McpSettings {
|
|
3
|
+
/** Levels of relations a tool's result includes. Deeper pulls whole relations into the agent's context. */
|
|
4
|
+
selectionDepth: number;
|
|
5
|
+
/** Largest entry one tool may have in the listing, in characters of JSON. */
|
|
6
|
+
maxToolSchemaChars: number;
|
|
7
|
+
/** Largest `tools/list` answer, in characters of JSON. Clients cut or refuse one much larger. */
|
|
8
|
+
maxToolListChars: number;
|
|
9
|
+
}
|
|
10
|
+
/** What the MCP helpers and `checkMcpBudget` use when the app overrides nothing. */
|
|
11
|
+
export declare const MCP_DEFAULTS: Readonly<McpSettings>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Every value someone might tune, as plain data. Nothing here computes, reads the environment or imports.
|
|
2
|
+
/** What the MCP helpers and `checkMcpBudget` use when the app overrides nothing. */
|
|
3
|
+
export const MCP_DEFAULTS = Object.freeze({
|
|
4
|
+
selectionDepth: 1,
|
|
5
|
+
maxToolSchemaChars: 40_000,
|
|
6
|
+
maxToolListChars: 250_000,
|
|
7
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpHttpRequest } from '@cubicecho/graphql-mcp';
|
|
2
|
+
/**
|
|
3
|
+
* Reads an MCP request's caller the way /graphql reads its own, so a credential means the same on both doors.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam TContext - The app's GraphQL context.
|
|
6
|
+
* @param contextFor - The factory /graphql uses: headers, and the client's address where there is one.
|
|
7
|
+
* @returns graphql-mcp's `contextFromRequest`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function contextFromRequest<TContext>(contextFor: (headers: Headers, ip?: string) => Promise<TContext>): (request: McpHttpRequest) => Promise<TContext>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toHeaders } from '../http/headers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads an MCP request's caller the way /graphql reads its own, so a credential means the same on both doors.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam TContext - The app's GraphQL context.
|
|
6
|
+
* @param contextFor - The factory /graphql uses: headers, and the client's address where there is one.
|
|
7
|
+
* @returns graphql-mcp's `contextFromRequest`.
|
|
8
|
+
*/
|
|
9
|
+
export function contextFromRequest(contextFor) {
|
|
10
|
+
return (request) => contextFor(toHeaders(request.headers), clientIp(request));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads a client's address.
|
|
14
|
+
*
|
|
15
|
+
* @param request - The MCP request.
|
|
16
|
+
* @returns Express's `ip`, which honors `trust proxy`, or undefined off Express: the socket's may be a proxy's.
|
|
17
|
+
*/
|
|
18
|
+
function clientIp(request) {
|
|
19
|
+
return 'ip' in request && typeof request.ip === 'string' ? request.ip : undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type HttpHandlerOptions } from '@cubicecho/graphql-mcp';
|
|
2
|
+
import { type McpSettings } from './defaults.ts';
|
|
3
|
+
/** What an app says about its tools. */
|
|
4
|
+
export interface ToolOptions extends Partial<Pick<McpSettings, 'selectionDepth'>> {
|
|
5
|
+
/**
|
|
6
|
+
* A line of orientation for a tool, by its MCP name (`create_task`). Generated fields only describe themselves as "the
|
|
7
|
+
* `tasks` query". Other tools are named in it by their MCP names too.
|
|
8
|
+
*/
|
|
9
|
+
hints?: Readonly<Record<string, string>>;
|
|
10
|
+
}
|
|
11
|
+
/** The part of graphql-mcp's options that is the same for every schema drizzle-graphql generates. */
|
|
12
|
+
export type SharedToolOptions = Required<Pick<HttpHandlerOptions, 'selectionDepth' | 'mutationHints' | 'nullBranches' | 'inputField' | 'decorate'>>;
|
|
13
|
+
/**
|
|
14
|
+
* Builds the options that keep a generated schema's tools small enough to list. Spread them before the app's own.
|
|
15
|
+
*
|
|
16
|
+
* @param [options] - The app's hints, and the depth when it is not the default.
|
|
17
|
+
* @returns Options for `createHttpHandler` or `createServerFactory`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toolOptions({ hints, selectionDepth, }?: ToolOptions): SharedToolOptions;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MutationHints, NullBranches, OperationKind } from '@cubicecho/graphql-mcp';
|
|
2
|
+
import { getNamedType } from 'graphql';
|
|
3
|
+
import { MCP_DEFAULTS } from './defaults.js';
|
|
4
|
+
/** How drizzle-graphql ends the names of a table's filter and order types. */
|
|
5
|
+
const TABLE_INPUTS = ['Filters', 'OrderBy'];
|
|
6
|
+
/** How it ends a to-many relation filter's. */
|
|
7
|
+
const LIST_RELATION_FILTER = 'ListRelationFilter';
|
|
8
|
+
/**
|
|
9
|
+
* Builds the options that keep a generated schema's tools small enough to list. Spread them before the app's own.
|
|
10
|
+
*
|
|
11
|
+
* @param [options] - The app's hints, and the depth when it is not the default.
|
|
12
|
+
* @returns Options for `createHttpHandler` or `createServerFactory`.
|
|
13
|
+
*/
|
|
14
|
+
export function toolOptions({ hints = {}, selectionDepth = MCP_DEFAULTS.selectionDepth, } = {}) {
|
|
15
|
+
return {
|
|
16
|
+
selectionDepth,
|
|
17
|
+
// Read-only and destructive hints, from the create, update and delete prefixes.
|
|
18
|
+
mutationHints: MutationHints.byName,
|
|
19
|
+
// An explicit null on a write is how a model says "clear". On a filter it means nothing and costs bytes.
|
|
20
|
+
nullBranches: (_field, kind) => (kind === OperationKind.query ? NullBranches.never : NullBranches.always),
|
|
21
|
+
inputField: isOwnColumn,
|
|
22
|
+
decorate: ({ name, description }) => {
|
|
23
|
+
const hint = Object.hasOwn(hints, name) ? hints[name] : undefined;
|
|
24
|
+
return { description: hint === undefined ? description : `${hint}\n\n${description}` };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Says whether an input field stays in a tool's schema.
|
|
30
|
+
*
|
|
31
|
+
* @param field - A field of a generated input type.
|
|
32
|
+
* @param parent - The type it is a field of.
|
|
33
|
+
* @returns false for a filter or order on another table, which pulls in that table's whole type, and its relations'.
|
|
34
|
+
*/
|
|
35
|
+
function isOwnColumn(field, parent) {
|
|
36
|
+
const { name } = getNamedType(field.type);
|
|
37
|
+
const isTableInput = TABLE_INPUTS.some((suffix) => name.endsWith(suffix));
|
|
38
|
+
const isAnotherTable = isTableInput && name !== parent.name;
|
|
39
|
+
const isRelation = isAnotherTable || name.endsWith(LIST_RELATION_FILTER);
|
|
40
|
+
return isRelation === false;
|
|
41
|
+
}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { McpSettings } from '../mcp/defaults.ts';
|
|
2
|
+
import { type ListedTool } from './mcp-problems.ts';
|
|
1
3
|
import { type PostgresFiles } from './postgres-problems.ts';
|
|
2
4
|
import { type SchemaExceptions } from './schema-problems.ts';
|
|
5
|
+
export { type ListedTool, mcpProblems } from './mcp-problems.ts';
|
|
3
6
|
export { type PostgresFiles, type PostgresFindings, postgresProblems } from './postgres-problems.ts';
|
|
4
7
|
export { type SchemaExceptions, schemaProblems } from './schema-problems.ts';
|
|
5
8
|
/**
|
|
@@ -15,3 +18,10 @@ export declare function checkSchemaConventions(schema: Record<string, unknown>,
|
|
|
15
18
|
* @param files - Where the repo names them.
|
|
16
19
|
*/
|
|
17
20
|
export declare function checkPostgresVersion(files: PostgresFiles): void;
|
|
21
|
+
/**
|
|
22
|
+
* Registers the test that an MCP listing fits the size budgets.
|
|
23
|
+
*
|
|
24
|
+
* @param listTools - Lists every tool the server offers, through a real client.
|
|
25
|
+
* @param [overrides] - Budgets that replace the defaults.
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkMcpBudget(listTools: () => Promise<readonly ListedTool[]>, overrides?: Partial<Pick<McpSettings, 'maxToolSchemaChars' | 'maxToolListChars'>>): void;
|
package/dist/testing/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { mcpProblems } from './mcp-problems.js';
|
|
3
4
|
import { postgresProblems } from './postgres-problems.js';
|
|
4
5
|
import { schemaProblems } from './schema-problems.js';
|
|
6
|
+
export { mcpProblems } from './mcp-problems.js';
|
|
5
7
|
export { postgresProblems } from './postgres-problems.js';
|
|
6
8
|
export { schemaProblems } from './schema-problems.js';
|
|
7
9
|
/**
|
|
@@ -38,6 +40,17 @@ export function checkPostgresVersion(files) {
|
|
|
38
40
|
expect(problems).toEqual([]);
|
|
39
41
|
});
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Registers the test that an MCP listing fits the size budgets.
|
|
45
|
+
*
|
|
46
|
+
* @param listTools - Lists every tool the server offers, through a real client.
|
|
47
|
+
* @param [overrides] - Budgets that replace the defaults.
|
|
48
|
+
*/
|
|
49
|
+
export function checkMcpBudget(listTools, overrides = {}) {
|
|
50
|
+
it('lists MCP tools within the size budgets', async () => {
|
|
51
|
+
expect(mcpProblems(await listTools(), overrides)).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
41
54
|
/**
|
|
42
55
|
* Asks the tests' Postgres for its major.
|
|
43
56
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type McpSettings } from '../mcp/defaults.ts';
|
|
2
|
+
/** A tool as `tools/list` answers it. */
|
|
3
|
+
export interface ListedTool {
|
|
4
|
+
/** The tool's name. */
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Measures a tool listing against the size budgets.
|
|
9
|
+
*
|
|
10
|
+
* @param tools - The tools, as a client was answered them.
|
|
11
|
+
* @param [overrides] - Budgets that replace the defaults.
|
|
12
|
+
* @returns What is over.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mcpProblems(tools: readonly ListedTool[], overrides?: Partial<Pick<McpSettings, 'maxToolSchemaChars' | 'maxToolListChars'>>): string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MCP_DEFAULTS } from '../mcp/defaults.js';
|
|
2
|
+
/**
|
|
3
|
+
* Measures a tool listing against the size budgets.
|
|
4
|
+
*
|
|
5
|
+
* @param tools - The tools, as a client was answered them.
|
|
6
|
+
* @param [overrides] - Budgets that replace the defaults.
|
|
7
|
+
* @returns What is over.
|
|
8
|
+
*/
|
|
9
|
+
export function mcpProblems(tools, overrides = {}) {
|
|
10
|
+
const { maxToolSchemaChars, maxToolListChars } = { ...MCP_DEFAULTS, ...overrides };
|
|
11
|
+
if (tools.length === 0) {
|
|
12
|
+
return ['the listing has no tools'];
|
|
13
|
+
}
|
|
14
|
+
const large = tools
|
|
15
|
+
.map((tool) => ({ name: tool.name, size: JSON.stringify(tool).length }))
|
|
16
|
+
.filter(({ size }) => size > maxToolSchemaChars)
|
|
17
|
+
.map(({ name, size }) => `${name} is ${size} characters, and ${maxToolSchemaChars} is the most for one tool`);
|
|
18
|
+
const total = JSON.stringify({ tools }).length;
|
|
19
|
+
const isOver = total > maxToolListChars;
|
|
20
|
+
return isOver
|
|
21
|
+
? [...large, `the listing is ${total} characters, and ${maxToolListChars} is the most for all of them`]
|
|
22
|
+
: large;
|
|
23
|
+
}
|
package/llms.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Agent-facing docs for @cubicecho/server-kit: one task or concept per page, then what each package.json "exports" entry exports. Generated from _agents/docs/ and the doc comments in src/ by @cubicecho/agent-docs; edit those, not this file.
|
|
6
6
|
|
|
7
|
-
Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@electric-sql/pglite` ^0.5.0 (optional), `better-auth` >=1.7.28 <1.8.0, `drizzle-orm` 1.0.0-rc.5, `express` ^5.0.0, `graphql` ^16.0.0, `graphql-yoga` ^6.0.0, `postgres` ^3.4.0, `vitest` ^5.0.0 (optional).
|
|
7
|
+
Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@cubicecho/graphql-mcp` ^3.1.0 (optional), `@electric-sql/pglite` ^0.5.0 (optional), `better-auth` >=1.7.28 <1.8.0, `drizzle-orm` 1.0.0-rc.5, `express` ^5.0.0, `graphql` ^16.0.0, `graphql-yoga` ^6.0.0, `postgres` ^3.4.0, `vitest` ^5.0.0 (optional).
|
|
8
8
|
|
|
9
9
|
## Docs
|
|
10
10
|
|
|
@@ -14,6 +14,7 @@ Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@ele
|
|
|
14
14
|
- [Auth preset](_agents/docs/04-auth.md): `@cubicecho/server-kit/auth` has the better-auth options and sign-in plugins every server shares: sessions in Postgres, bearer tokens, emailed links, and OIDC with pairing. The app still calls `betterAuth`, so it adds its own plugins and hooks and keeps exact types.
|
|
15
15
|
- [GraphQL](_agents/docs/05-graphql.md): `@cubicecho/server-kit/graphql` has what every Yoga 6 server shares: operation limits, coded errors, input validation and a logger that never prints a request's variables.
|
|
16
16
|
- [HTTP](_agents/docs/06-http.md): `@cubicecho/server-kit/http` has what surrounds an Express app: a clean stop, the health check, serving the built app, and the two OIDC redirects.
|
|
17
|
+
- [MCP](_agents/docs/07-mcp.md): `@cubicecho/server-kit/mcp` has what every MCP door over a drizzle-graphql schema shares: how the caller is read, and the options that keep the listing small. It needs `@cubicecho/graphql-mcp`, an optional peer.
|
|
17
18
|
- [Common mistakes](_agents/docs/common-mistakes.md): What goes wrong when the kit is wired up slightly differently, and the fix for each.
|
|
18
19
|
|
|
19
20
|
## Exports: @cubicecho/server-kit/auth
|
|
@@ -96,6 +97,7 @@ Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@ele
|
|
|
96
97
|
- `oidcSignInUrl`: Names where a login button sends the browser.
|
|
97
98
|
- `HTTP_DEFAULTS`: What the HTTP helpers use when the app overrides nothing.
|
|
98
99
|
- `HttpSettings` (type): Settings for the HTTP doors and the process behind them.
|
|
100
|
+
- `toHeaders`: Copies Node's headers into fetch `Headers`, which better-auth reads the caller from.
|
|
99
101
|
- `checkHealth`: Round-trips to Postgres.
|
|
100
102
|
- `Health` (type): What `/healthz` answers.
|
|
101
103
|
- `drain`: Stops accepting connections, and waits for every request to finish.
|
|
@@ -105,8 +107,19 @@ Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@ele
|
|
|
105
107
|
- `StaticHandler` (type): A request handler, for Express or plain `node:http`.
|
|
106
108
|
- `HttpStatus`: The HTTP statuses a server sends, and its tests expect.
|
|
107
109
|
|
|
110
|
+
## Exports: @cubicecho/server-kit/mcp
|
|
111
|
+
|
|
112
|
+
- `MCP_DEFAULTS`: What the MCP helpers and `checkMcpBudget` use when the app overrides nothing.
|
|
113
|
+
- `McpSettings` (type): Bounds on the MCP door.
|
|
114
|
+
- `contextFromRequest`: Reads an MCP request's caller the way /graphql reads its own, so a credential means the same on both doors.
|
|
115
|
+
- `SharedToolOptions` (type): The part of graphql-mcp's options that is the same for every schema drizzle-graphql generates.
|
|
116
|
+
- `ToolOptions` (type): What an app says about its tools.
|
|
117
|
+
- `toolOptions`: Builds the options that keep a generated schema's tools small enough to list.
|
|
118
|
+
|
|
108
119
|
## Exports: @cubicecho/server-kit/testing
|
|
109
120
|
|
|
121
|
+
- `ListedTool` (type): A tool as `tools/list` answers it.
|
|
122
|
+
- `mcpProblems`: Measures a tool listing against the size budgets.
|
|
110
123
|
- `PostgresFiles` (type): Where a repo says which Postgres it runs.
|
|
111
124
|
- `PostgresFindings` (type): What a comparison found.
|
|
112
125
|
- `postgresProblems`: Compares the Postgres majors a repo names with each other and with the one its tests run on.
|
|
@@ -114,3 +127,4 @@ Requires Node >=22. Peer dependencies: `@better-auth/sso` >=1.7.28 <1.8.0, `@ele
|
|
|
114
127
|
- `schemaProblems`: Finds what breaks the table conventions.
|
|
115
128
|
- `checkSchemaConventions`: Registers the tests that hold a schema to the table conventions: ids, join tables, time zones and foreign-key indexes.
|
|
116
129
|
- `checkPostgresVersion`: Registers the test that a repo's compose files, CI and tests agree on a Postgres major.
|
|
130
|
+
- `checkMcpBudget`: Registers the test that an MCP listing fits the size budgets.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubicecho/server-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The server code every cubicecho GraphQL backend shares: database boot, id columns and the checks that keep a schema to the standard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Benjamin Van Treese",
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"types": "./dist/http/index.d.ts",
|
|
44
44
|
"import": "./dist/http/index.js"
|
|
45
45
|
},
|
|
46
|
+
"./mcp": {
|
|
47
|
+
"types": "./dist/mcp/index.d.ts",
|
|
48
|
+
"import": "./dist/mcp/index.js"
|
|
49
|
+
},
|
|
46
50
|
"./testing": {
|
|
47
51
|
"types": "./dist/testing/index.d.ts",
|
|
48
52
|
"import": "./dist/testing/index.js"
|
|
@@ -68,6 +72,7 @@
|
|
|
68
72
|
},
|
|
69
73
|
"peerDependencies": {
|
|
70
74
|
"@better-auth/sso": ">=1.7.28 <1.8.0",
|
|
75
|
+
"@cubicecho/graphql-mcp": "^3.1.0",
|
|
71
76
|
"@electric-sql/pglite": "^0.5.0",
|
|
72
77
|
"better-auth": ">=1.7.28 <1.8.0",
|
|
73
78
|
"drizzle-orm": "1.0.0-rc.5",
|
|
@@ -78,6 +83,9 @@
|
|
|
78
83
|
"vitest": "^5.0.0"
|
|
79
84
|
},
|
|
80
85
|
"peerDependenciesMeta": {
|
|
86
|
+
"@cubicecho/graphql-mcp": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
81
89
|
"@electric-sql/pglite": {
|
|
82
90
|
"optional": true
|
|
83
91
|
},
|
|
@@ -89,7 +97,9 @@
|
|
|
89
97
|
"@better-auth/sso": "^1.7.28",
|
|
90
98
|
"@biomejs/biome": "^2.6.2",
|
|
91
99
|
"@cubicecho/agent-docs": "^0.2.0",
|
|
100
|
+
"@cubicecho/graphql-mcp": "^3.2.0",
|
|
92
101
|
"@electric-sql/pglite": "^0.5.17",
|
|
102
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
93
103
|
"@semantic-release/changelog": "^6.0.3",
|
|
94
104
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
95
105
|
"@semantic-release/git": "^10.0.1",
|