@ultimat3/mcp 31.46.0 → 31.47.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/README.md +8 -2
- package/package.json +11 -11
- package/src/dev-ui-interact.ts +3 -5
- package/src/meta-split-call.ts +2 -4
- package/src/protocol-era.ts +5 -7
- package/src/registry.ts +2 -5
- package/src/runtime-schema.ts +3 -6
- package/src/server-catalog.ts +2 -5
- package/src/tenant.ts +2 -5
package/README.md
CHANGED
|
@@ -110,7 +110,13 @@ user's app:
|
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
112
|
// apps/admin/app/admin/mcp.ts — under app/, so the app scan imports it
|
|
113
|
-
import { defineAppMcp, t } from '@ultimat3/mcp';
|
|
113
|
+
import { defineAppMcp, type McpResource, type ResolvedToken, t } from '@ultimat3/mcp';
|
|
114
|
+
import { type Actor } from '@ultimat3/core';
|
|
115
|
+
|
|
116
|
+
declare const orgExport: McpResource;
|
|
117
|
+
declare const sessions: { resolveAgentToken(token: string): Promise<ResolvedToken | null> };
|
|
118
|
+
declare function orgOf(actor: Actor): string;
|
|
119
|
+
declare function seats(org: { id: string; name: string }): { used: number; limit: number };
|
|
114
120
|
|
|
115
121
|
export const mcp = defineAppMcp({
|
|
116
122
|
name: 'acme-admin',
|
|
@@ -124,7 +130,7 @@ export const mcp = defineAppMcp({
|
|
|
124
130
|
policy: 'org:administer', // an existing permission, never a new rule
|
|
125
131
|
destructive: false,
|
|
126
132
|
async handle({ ctx }) {
|
|
127
|
-
return seats(await ctx.orgs.byId(ctx.actor
|
|
133
|
+
return seats(await ctx.orgs.byId(orgOf(ctx.actor)));
|
|
128
134
|
},
|
|
129
135
|
},
|
|
130
136
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/mcp",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.47.0",
|
|
4
4
|
"description": "MCP server, dev tools, and the action-to-tool projection \u2014 one authz system, two surfaces",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"test": "bun test"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ultimat3/action": "31.
|
|
48
|
-
"@ultimat3/auth": "31.
|
|
49
|
-
"@ultimat3/core": "31.
|
|
50
|
-
"@ultimat3/db": "31.
|
|
51
|
-
"@ultimat3/entity": "31.
|
|
52
|
-
"@ultimat3/http": "31.
|
|
53
|
-
"@ultimat3/jobs": "31.
|
|
54
|
-
"@ultimat3/policy": "31.
|
|
55
|
-
"@ultimat3/query": "31.
|
|
56
|
-
"@ultimat3/schema": "31.
|
|
47
|
+
"@ultimat3/action": "31.47.0",
|
|
48
|
+
"@ultimat3/auth": "31.47.0",
|
|
49
|
+
"@ultimat3/core": "31.47.0",
|
|
50
|
+
"@ultimat3/db": "31.47.0",
|
|
51
|
+
"@ultimat3/entity": "31.47.0",
|
|
52
|
+
"@ultimat3/http": "31.47.0",
|
|
53
|
+
"@ultimat3/jobs": "31.47.0",
|
|
54
|
+
"@ultimat3/policy": "31.47.0",
|
|
55
|
+
"@ultimat3/query": "31.47.0",
|
|
56
|
+
"@ultimat3/schema": "31.47.0"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/dev-ui-interact.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// the picture is of. The schema's job is the SHAPE of a step (`anyOf` over five one-key objects);
|
|
12
12
|
// the CLI's is the count, the lengths and the policies.
|
|
13
13
|
|
|
14
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
14
15
|
import type {
|
|
15
16
|
UiColorScheme,
|
|
16
17
|
UiInspectActive,
|
|
@@ -143,13 +144,10 @@ export const UI_INTERACT_STEP_SCHEMA: JsonSchema = {
|
|
|
143
144
|
],
|
|
144
145
|
};
|
|
145
146
|
|
|
146
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
147
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
148
|
-
|
|
149
147
|
/** Everything array-shaped goes through; the CLI is the parser, and it refuses whole. */
|
|
150
148
|
const stepsOf = (value: unknown): readonly Readonly<Record<string, unknown>>[] =>
|
|
151
149
|
Array.isArray(value)
|
|
152
|
-
? value.map((item): Readonly<Record<string, unknown>> => (
|
|
150
|
+
? value.map((item): Readonly<Record<string, unknown>> => (isJsonObject(item) ? item : {}))
|
|
153
151
|
: [];
|
|
154
152
|
|
|
155
153
|
/** The one `ui.interact` tool, spread into the dev catalog beside the three `ui.*` eyes. */
|
|
@@ -199,7 +197,7 @@ export function uiInteractTools(host: UiInteractHost, scope: string): readonly A
|
|
|
199
197
|
},
|
|
200
198
|
async handle(args: ToolArgs) {
|
|
201
199
|
const route = typeof args['route'] === 'string' ? args['route'] : '';
|
|
202
|
-
const asked =
|
|
200
|
+
const asked = isJsonObject(args['inspect']) ? inspectSpecOf(args['inspect']) : undefined;
|
|
203
201
|
const result = await host.interactRoute({
|
|
204
202
|
route,
|
|
205
203
|
viewport: viewportOf(args),
|
package/src/meta-split-call.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// for `delete_resource`, preview unless `live: true`, and commit only with `confirmed_by_user:
|
|
4
4
|
// true` → the server's `dispatch`. Every call that runs goes through the flat path's one dispatch.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import {
|
|
7
8
|
McpUserConfirmationRequiredError,
|
|
8
9
|
McpWrongToolError,
|
|
@@ -51,7 +52,7 @@ export async function splitCall(
|
|
|
51
52
|
const wrong = new McpWrongToolError({ resource, action, called: name, useTool });
|
|
52
53
|
return host.refuse(id, action, wrong, caller);
|
|
53
54
|
}
|
|
54
|
-
const params =
|
|
55
|
+
const params = isJsonObject(args['params']) ? args['params'] : {};
|
|
55
56
|
if (name !== DELETE_RESOURCE) {
|
|
56
57
|
return host.dispatch(id, action, resolveAddressed(host, tool, params, caller), caller);
|
|
57
58
|
}
|
|
@@ -124,6 +125,3 @@ function liftToolArgs(
|
|
|
124
125
|
if (ownsPreview) rest[LIVE] = live;
|
|
125
126
|
return { params: rest, live, confirmed: pick(CONFIRMED), ownsPreview };
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
129
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
package/src/protocol-era.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// every modern result carries, and the mirrored-header check HTTP owes a modern request. Split from
|
|
4
4
|
// `server.ts` so that file stays a dispatch. MCP 2026-07-28, `basic/versioning`.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import { McpHeaderMismatchError, McpProtocolUnsupportedError } from './errors-transport';
|
|
7
8
|
import { SPLIT_DISPATCHERS } from './meta-split';
|
|
8
9
|
import type { MetaSurface } from './meta-surface';
|
|
@@ -73,7 +74,7 @@ export const CAPABILITIES = {
|
|
|
73
74
|
/** The `_meta` version a request names, or `undefined` for one that names none. */
|
|
74
75
|
export function requestedVersion(body: JsonRpcRequest): unknown {
|
|
75
76
|
const meta = paramsOf(body)?.['_meta'];
|
|
76
|
-
return
|
|
77
|
+
return isJsonObject(meta) ? meta[META_PROTOCOL_VERSION] : undefined;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
/**
|
|
@@ -134,8 +135,8 @@ export function stamped(
|
|
|
134
135
|
serverInfo: ServerInfo,
|
|
135
136
|
): JsonRpcResponse {
|
|
136
137
|
const result = response.result;
|
|
137
|
-
if (!
|
|
138
|
-
const meta =
|
|
138
|
+
if (!isJsonObject(result)) return response;
|
|
139
|
+
const meta = isJsonObject(result['_meta']) ? result['_meta'] : {};
|
|
139
140
|
return resultResponse(response.id, {
|
|
140
141
|
...result,
|
|
141
142
|
resultType: 'complete',
|
|
@@ -168,7 +169,7 @@ export function classifyBody(
|
|
|
168
169
|
if (meta !== undefined && (name === MANAGE_RESOURCE || SPLIT_DISPATCHERS.includes(name))) {
|
|
169
170
|
// Billed as the tool it reaches, so the dispatcher is never a cheap door to a write.
|
|
170
171
|
const args = params?.['arguments'];
|
|
171
|
-
const action =
|
|
172
|
+
const action = isJsonObject(args) ? args['action'] : undefined;
|
|
172
173
|
return typeof action === 'string' ? tools.verbClass(action) : 'write';
|
|
173
174
|
}
|
|
174
175
|
if (meta !== undefined && META_TOOL_NAMES.includes(name)) return 'read';
|
|
@@ -265,6 +266,3 @@ export function httpStatusOf(body: unknown, response: JsonRpcResponse): number {
|
|
|
265
266
|
}
|
|
266
267
|
return 200;
|
|
267
268
|
}
|
|
268
|
-
|
|
269
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
270
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
package/src/registry.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// narrow token; a token holding every scope still cannot see a tool its role may not.
|
|
20
20
|
|
|
21
21
|
import type { Actor, McpEffect } from '@ultimat3/core';
|
|
22
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
22
23
|
import { McpToolDuplicateError } from './errors';
|
|
23
24
|
import type { McpListParams } from './list-params';
|
|
24
25
|
import type { ArgIssue } from './validate-args';
|
|
@@ -329,13 +330,9 @@ export class ToolRegistry {
|
|
|
329
330
|
*/
|
|
330
331
|
resolve(name: string, rawArgs: unknown, caller: McpCaller): ToolResolution {
|
|
331
332
|
const arg = this.#tenantArg;
|
|
332
|
-
const isRecord = typeof rawArgs === 'object' && rawArgs !== null && !Array.isArray(rawArgs);
|
|
333
333
|
// A non-record stays as it is rather than becoming `{}`: validation refuses it as a whole, and
|
|
334
334
|
// an empty object here would answer a malformed call as an argument-less one.
|
|
335
|
-
const args =
|
|
336
|
-
arg === undefined || !isRecord
|
|
337
|
-
? rawArgs
|
|
338
|
-
: withoutKey(rawArgs as Readonly<Record<string, unknown>>, arg);
|
|
335
|
+
const args = arg === undefined || !isJsonObject(rawArgs) ? rawArgs : withoutKey(rawArgs, arg);
|
|
339
336
|
const found = this.#tools.get(name);
|
|
340
337
|
const tool = found === undefined || !visibleToCaller(found, caller) ? undefined : found;
|
|
341
338
|
if (tool === undefined) {
|
package/src/runtime-schema.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// keyword outside the subset (`format`, `oneOf`, `$ref`) would be PUBLISHED and never enforced — so
|
|
6
6
|
// it is refused, never dropped: dropping a constraint the author wrote widens the tool silently.
|
|
7
7
|
|
|
8
|
-
import { renderCauseValue } from '@ultimat3/core';
|
|
8
|
+
import { isJsonObject, renderCauseValue } from '@ultimat3/core';
|
|
9
9
|
import { McpCatalogUnresolvedError } from './catalog-errors';
|
|
10
10
|
import type { JsonSchema } from './wire';
|
|
11
11
|
|
|
@@ -54,7 +54,7 @@ export function runtimeInputSchema(tool: string, value: unknown): JsonSchema {
|
|
|
54
54
|
|
|
55
55
|
function node(tool: string, value: unknown, at: string, depth: number): JsonSchema {
|
|
56
56
|
if (depth > MAX_DEPTH) refuse(tool, at, `nests deeper than ${MAX_DEPTH}`);
|
|
57
|
-
if (!
|
|
57
|
+
if (!isJsonObject(value)) refuse(tool, at, 'is not a JSON Schema object');
|
|
58
58
|
const out: Record<string, unknown> = {};
|
|
59
59
|
for (const [key, child] of Object.entries(value)) {
|
|
60
60
|
if (!KEYWORDS.has(key)) {
|
|
@@ -71,7 +71,7 @@ function keyword(tool: string, key: string, value: unknown, at: string, depth: n
|
|
|
71
71
|
if (!TYPES.has(value)) refuse(tool, at, 'is not a JSON Schema type');
|
|
72
72
|
return value;
|
|
73
73
|
case 'properties': {
|
|
74
|
-
if (!
|
|
74
|
+
if (!isJsonObject(value)) refuse(tool, at, 'is not an object');
|
|
75
75
|
const out: Record<string, unknown> = {};
|
|
76
76
|
for (const [name, child] of Object.entries(value)) {
|
|
77
77
|
put(out, name, node(tool, child, `${at}.${name}`, depth + 1));
|
|
@@ -125,8 +125,5 @@ function refuse(tool: string, at: string, why: string): never {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
129
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
130
|
-
|
|
131
128
|
const isScalar = (value: unknown): value is string | number | boolean | null =>
|
|
132
129
|
value === null || ['string', 'number', 'boolean'].includes(typeof value);
|
package/src/server-catalog.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Never a smaller catalog, never one name twice.
|
|
6
6
|
|
|
7
7
|
import type { ErrorAudience } from '@ultimat3/core';
|
|
8
|
-
import { fixFor, logger, stringField } from '@ultimat3/core';
|
|
8
|
+
import { fixFor, isJsonObject, logger, stringField } from '@ultimat3/core';
|
|
9
9
|
import type { McpCatalogNameSource } from './catalog-errors';
|
|
10
10
|
import { McpCatalogToolDuplicateError, McpCatalogUnresolvedError } from './catalog-errors';
|
|
11
11
|
import { asFrameworkError, forAudience } from './framework-error';
|
|
@@ -133,7 +133,7 @@ export async function catalogFor(boot: CatalogBoot, caller: McpCaller): Promise<
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
function merge(boot: CatalogBoot, resolved: McpResolvedCatalog): CatalogView {
|
|
136
|
-
if (!
|
|
136
|
+
if (!isJsonObject(resolved) || !Array.isArray(resolved.tools)) {
|
|
137
137
|
throw new McpCatalogUnresolvedError({
|
|
138
138
|
cause: 'the catalog resolver answered something other than { tools: [...] }',
|
|
139
139
|
});
|
|
@@ -195,6 +195,3 @@ function refused<T>(check: () => T): T {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
200
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
package/src/tenant.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// Only `tools/call` comes through here: every other method runs as the person, in no tenant.
|
|
10
10
|
|
|
11
11
|
import type { Actor } from '@ultimat3/core';
|
|
12
|
-
import { logger, renderCauseValue, renderThrowable } from '@ultimat3/core';
|
|
12
|
+
import { isJsonObject, logger, renderCauseValue, renderThrowable } from '@ultimat3/core';
|
|
13
13
|
import {
|
|
14
14
|
McpTenantInvalidError,
|
|
15
15
|
McpTenantRequiredError,
|
|
@@ -141,7 +141,7 @@ export async function tenantStep(
|
|
|
141
141
|
rawArgs: unknown,
|
|
142
142
|
caller: McpCaller,
|
|
143
143
|
): Promise<TenantStep> {
|
|
144
|
-
const args =
|
|
144
|
+
const args = isJsonObject(rawArgs) ? rawArgs : {};
|
|
145
145
|
const value = Object.hasOwn(args, tenant.arg) ? args[tenant.arg] : undefined;
|
|
146
146
|
if (typeof value !== 'string' || value.length === 0) {
|
|
147
147
|
return { kind: 'refused', error: new McpTenantRequiredError({ arg: tenant.arg }) };
|
|
@@ -176,6 +176,3 @@ function unresolved(cause: string, thrown?: unknown): TenantStep {
|
|
|
176
176
|
logger.error('mcp.tenant.unresolved', { surface: 'mcp', code: error.code, cause: error.cause });
|
|
177
177
|
return { kind: 'refused', error };
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
181
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|