pull/715/head
Travis Fischer 2025-06-12 05:32:58 +07:00
rodzic 36a7de985c
commit 4fff3f989a
8 zmienionych plików z 94 dodań i 132 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`HTTP => MCP origin basic "add" tool call success > 5.0: POST @dev/test-basic-mcp/add 1`] = ` exports[`HTTP => MCP origin basic "add" tool > 5.0: POST @dev/test-basic-mcp/add 1`] = `
[ [
{ {
"text": "42", "text": "42",
@ -9,7 +9,7 @@ exports[`HTTP => MCP origin basic "add" tool call success > 5.0: POST @dev/test-
] ]
`; `;
exports[`HTTP => MCP origin basic "add" tool call success > 5.1: GET @dev/test-basic-mcp/add 1`] = ` exports[`HTTP => MCP origin basic "add" tool > 5.1: GET @dev/test-basic-mcp/add 1`] = `
[ [
{ {
"text": "42", "text": "42",

Wyświetl plik

@ -1,49 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`MCP => MCP origin basic "echo" tool > 10.0: @dev/test-basic-mcp/mcp echo 1`] = `
{
"content": [
{
"text": "{"nala":"kitten","num":123,"now":1749678890348}",
"type": "text",
},
],
}
`;
exports[`MCP => MCP origin basic "echo" tool with empty body > 13.0: @dev/test-basic-mcp/mcp echo 1`] = `
{
"content": [
{
"text": "{}",
"type": "text",
},
],
}
`;
exports[`MCP => MCP origin basic "pure" tool > 11.0: @dev/test-basic-mcp/mcp echo 1`] = `
{
"content": [
{
"text": "{"nala":"kitten","foo":"bar"}",
"type": "text",
},
],
}
`;
exports[`MCP => MCP origin basic "pure" tool > 11.1: @dev/test-basic-mcp/mcp echo 1`] = `
{
"content": [
{
"text": "{"nala":"kitten","foo":"bar"}",
"type": "text",
},
],
}
`;
exports[`MCP => OpenAPI origin basic @ 010332cf get_post success > 2.0: @dev/test-basic-openapi@010332cf/mcp get_post 1`] = ` exports[`MCP => OpenAPI origin basic @ 010332cf get_post success > 2.0: @dev/test-basic-openapi@010332cf/mcp get_post 1`] = `
{ {
"content": [], "content": [],
@ -204,6 +160,58 @@ nostrum rerum est autem sunt rem eveniet architecto",
} }
`; `;
exports[`MCP => OpenAPI origin everything "echo" tool with empty body > 13.0: @dev/test-everything-openapi/mcp echo 1`] = `
{
"content": [],
"isError": false,
"structuredContent": {},
}
`;
exports[`MCP => OpenAPI origin everything "pure" tool > 11.0: @dev/test-everything-openapi/mcp echo 1`] = `
{
"content": [],
"isError": false,
"structuredContent": {
"foo": "bar",
"nala": "kitten",
},
}
`;
exports[`MCP => OpenAPI origin everything "pure" tool > 11.1: @dev/test-everything-openapi/mcp echo 1`] = `
{
"content": [],
"isError": false,
"structuredContent": {
"foo": "bar",
"nala": "kitten",
},
}
`;
exports[`MCP => OpenAPI origin everything "unpure_marked_pure" tool > 14.0: @dev/test-everything-openapi/mcp unpure_marked_pure 1`] = `
{
"content": [],
"isError": false,
"structuredContent": {
"nala": "cat",
"now": 1749674829923,
},
}
`;
exports[`MCP => OpenAPI origin everything "unpure_marked_pure" tool > 14.1: @dev/test-everything-openapi/mcp unpure_marked_pure 1`] = `
{
"content": [],
"isError": false,
"structuredContent": {
"nala": "cat",
"now": 1749674829923,
},
}
`;
exports[`MCP => OpenAPI origin everything errors > 5.0: @dev/test-everything-openapi/mcp strict_additional_properties 1`] = ` exports[`MCP => OpenAPI origin everything errors > 5.0: @dev/test-everything-openapi/mcp strict_additional_properties 1`] = `
{ {
"content": [], "content": [],

Wyświetl plik

@ -128,7 +128,10 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
type: 'text', type: 'text',
text: JSON.stringify({ nala: 'kitten', num: 123, now }) text: JSON.stringify({ nala: 'kitten', num: 123, now })
} }
] ],
_agenticMeta: {
cacheStatus: 'DYNAMIC'
}
} }
}, },
{ {
@ -150,7 +153,10 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
now: `${now}` now: `${now}`
}) })
} }
] ],
_agenticMeta: {
cacheStatus: 'DYNAMIC'
}
} }
} }
] ]
@ -392,6 +398,7 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
{ {
title: 'MCP => MCP origin basic "echo" tool', title: 'MCP => MCP origin basic "echo" tool',
path: '@dev/test-basic-mcp/mcp', path: '@dev/test-basic-mcp/mcp',
stableSnapshot: false,
fixtures: [ fixtures: [
{ {
request: { request: {
@ -417,6 +424,7 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
{ {
title: 'MCP => OpenAPI origin everything "pure" tool', title: 'MCP => OpenAPI origin everything "pure" tool',
path: '@dev/test-everything-openapi/mcp', path: '@dev/test-everything-openapi/mcp',
compareResponseBodies: true,
fixtures: [ fixtures: [
{ {
request: { request: {
@ -436,15 +444,10 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
}, },
response: { response: {
isError: false, isError: false,
content: [ structuredContent: {
{
type: 'text',
text: JSON.stringify({
nala: 'kitten', nala: 'kitten',
foo: 'bar' foo: 'bar'
})
} }
]
} }
}, },
{ {
@ -466,15 +469,10 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
}, },
response: { response: {
isError: false, isError: false,
content: [ structuredContent: {
{
type: 'text',
text: JSON.stringify({
nala: 'kitten', nala: 'kitten',
foo: 'bar' foo: 'bar'
}) },
}
],
_agenticMeta: { _agenticMeta: {
cacheStatus: 'HIT' cacheStatus: 'HIT'
} }
@ -514,7 +512,7 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
}, },
response: { response: {
isError: false, isError: false,
content: [{ type: 'text', text: JSON.stringify({}) }] structuredContent: {}
} }
} }
] ]
@ -523,7 +521,6 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
title: 'MCP => OpenAPI origin everything "unpure_marked_pure" tool', title: 'MCP => OpenAPI origin everything "unpure_marked_pure" tool',
path: '@dev/test-everything-openapi/mcp', path: '@dev/test-everything-openapi/mcp',
compareResponseBodies: true, compareResponseBodies: true,
only: true,
fixtures: [ fixtures: [
{ {
request: { request: {
@ -535,7 +532,7 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
response: { response: {
isError: false, isError: false,
validate: (result) => { validate: (result) => {
const body = JSON.parse(result.content[0].text) const body = result.structuredContent
expect(body?.nala).toEqual('cat') expect(body?.nala).toEqual('cat')
expect(typeof body.now).toBe('number') expect(typeof body.now).toBe('number')
expect(body.now).toBeGreaterThan(0) expect(body.now).toBeGreaterThan(0)

Wyświetl plik

@ -71,7 +71,10 @@ export class DurableMcpServerBase extends McpAgent<
return undefined return undefined
} }
if (!pricingPlanToolConfig?.enabled && !toolConfig.enabled) { if (
pricingPlanToolConfig?.enabled !== true &&
toolConfig.enabled === false
) {
// Tool is disabled / hidden for all pricing plans // Tool is disabled / hidden for all pricing plans
return undefined return undefined
} }

Wyświetl plik

@ -129,6 +129,7 @@ export async function resolveOriginToolCall({
const pricingPlanToolOverride = pricingPlan const pricingPlanToolOverride = pricingPlan
? toolConfig.pricingPlanOverridesMap?.[pricingPlan.slug] ? toolConfig.pricingPlanOverridesMap?.[pricingPlan.slug]
: undefined : undefined
const isToolConfigEnabled = toolConfig.enabled ?? true
// Check if this tool is configured for pricing-plan-specific overrides // Check if this tool is configured for pricing-plan-specific overrides
// which take precedence over the tool's default behavior. // which take precedence over the tool's default behavior.
@ -136,11 +137,11 @@ export async function resolveOriginToolCall({
if (pricingPlanToolOverride.enabled !== undefined) { if (pricingPlanToolOverride.enabled !== undefined) {
assert( assert(
pricingPlanToolOverride.enabled, pricingPlanToolOverride.enabled,
toolConfig.enabled ? 403 : 404, isToolConfigEnabled ? 403 : 404,
`Tool "${tool.name}" is disabled for pricing plan "${pricingPlan.slug}"` `Tool "${tool.name}" is disabled for pricing plan "${pricingPlan.slug}"`
) )
} else { } else {
assert(toolConfig.enabled, 404, `Tool "${tool.name}" is disabled`) assert(isToolConfigEnabled, 404, `Tool "${tool.name}" is disabled`)
} }
if (pricingPlanToolOverride.reportUsage !== undefined) { if (pricingPlanToolOverride.reportUsage !== undefined) {
@ -152,7 +153,7 @@ export async function resolveOriginToolCall({
rateLimit = pricingPlanToolOverride.rateLimit as RateLimit rateLimit = pricingPlanToolOverride.rateLimit as RateLimit
} }
} else { } else {
assert(toolConfig.enabled, 404, `Tool "${tool.name}" is disabled`) assert(isToolConfigEnabled, 404, `Tool "${tool.name}" is disabled`)
} }
} else { } else {
if (cacheControl) { if (cacheControl) {

Wyświetl plik

@ -56,18 +56,12 @@ exports[`loadAgenticConfig > basic-openapi 1`] = `
], ],
"toolConfigs": [ "toolConfigs": [
{ {
"additionalProperties": true,
"enabled": true,
"name": "get_posts", "name": "get_posts",
"pure": true, "pure": true,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "get_post", "name": "get_post",
"pure": true, "pure": true,
"reportUsage": true,
}, },
], ],
"version": undefined, "version": undefined,
@ -159,7 +153,6 @@ exports[`loadAgenticConfig > everything-openapi 1`] = `
], ],
"toolConfigs": [ "toolConfigs": [
{ {
"additionalProperties": true,
"enabled": true, "enabled": true,
"name": "get_user", "name": "get_user",
"pricingPlanOverridesMap": { "pricingPlanOverridesMap": {
@ -173,88 +166,53 @@ exports[`loadAgenticConfig > everything-openapi 1`] = `
"reportUsage": true, "reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": false, "enabled": false,
"name": "disabled_tool", "name": "disabled_tool",
"pure": false,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "disabled_for_free_plan_tool", "name": "disabled_for_free_plan_tool",
"pricingPlanOverridesMap": { "pricingPlanOverridesMap": {
"free": { "free": {
"enabled": false, "enabled": false,
}, },
}, },
"pure": false,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "pure", "name": "pure",
"pure": true, "pure": true,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "unpure_marked_pure", "name": "unpure_marked_pure",
"pure": true, "pure": true,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"cacheControl": "public, max-age=7200, s-maxage=7200, stale-while-revalidate=3600", "cacheControl": "public, max-age=7200, s-maxage=7200, stale-while-revalidate=3600",
"enabled": true,
"name": "custom_cache_control_tool", "name": "custom_cache_control_tool",
"pure": false,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"cacheControl": "no-cache", "cacheControl": "no-cache",
"enabled": true,
"name": "no_cache_cache_control_tool", "name": "no_cache_cache_control_tool",
"pure": false,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"cacheControl": "no-store", "cacheControl": "no-store",
"enabled": true,
"name": "no_store_cache_control_tool", "name": "no_store_cache_control_tool",
"pure": false,
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "custom_rate_limit_tool", "name": "custom_rate_limit_tool",
"pure": false,
"rateLimit": { "rateLimit": {
"async": true, "async": true,
"interval": 30, "interval": 30,
"maxPerInterval": 10, "maxPerInterval": 10,
}, },
"reportUsage": true,
}, },
{ {
"additionalProperties": true,
"enabled": true,
"name": "disabled_rate_limit_tool", "name": "disabled_rate_limit_tool",
"pure": false,
"rateLimit": null, "rateLimit": null,
"reportUsage": true,
}, },
{ {
"additionalProperties": false, "inputSchemaAdditionalProperties": false,
"enabled": true,
"name": "strict_additional_properties", "name": "strict_additional_properties",
"pure": false, "outputSchemaAdditionalProperties": false,
"reportUsage": true,
}, },
], ],
"version": undefined, "version": undefined,

Wyświetl plik

@ -497,18 +497,13 @@ export interface components {
ToolConfig: { ToolConfig: {
/** @description Agentic tool name */ /** @description Agentic tool name */
name: string; name: string;
/** @default true */ enabled?: boolean;
enabled: boolean; pure?: boolean;
/** @default false */
pure: boolean;
cacheControl?: string; cacheControl?: string;
/** @default true */ reportUsage?: boolean;
reportUsage: boolean;
rateLimit?: components["schemas"]["RateLimit"] | null; rateLimit?: components["schemas"]["RateLimit"] | null;
/** @default true */ inputSchemaAdditionalProperties?: boolean;
inputSchemaAdditionalProperties: boolean; outputSchemaAdditionalProperties?: boolean;
/** @default true */
outputSchemaAdditionalProperties: boolean;
/** @description Allows you to override this tool's behavior or disable it entirely for different pricing plans. This is a map of PricingPlan slug to PricingPlanToolOverrides for that plan. */ /** @description Allows you to override this tool's behavior or disable it entirely for different pricing plans. This is a map of PricingPlan slug to PricingPlanToolOverrides for that plan. */
pricingPlanOverridesMap?: { pricingPlanOverridesMap?: {
[key: string]: components["schemas"]["PricingPlanToolOverride"]; [key: string]: components["schemas"]["PricingPlanToolOverride"];

Wyświetl plik

@ -107,7 +107,7 @@ export const toolConfigSchema = z
* *
* @default true * @default true
*/ */
enabled: z.boolean().optional().default(true), enabled: z.boolean().optional(),
/** /**
* Whether this tool's output is deterministic and idempotent given the * Whether this tool's output is deterministic and idempotent given the
@ -122,7 +122,7 @@ export const toolConfigSchema = z
* *
* @default false * @default false
*/ */
pure: z.boolean().optional().default(false), pure: z.boolean().optional(),
/** /**
* A custom `Cache-Control` header to use for caching this tool's responses. * A custom `Cache-Control` header to use for caching this tool's responses.
@ -153,7 +153,7 @@ export const toolConfigSchema = z
* *
* @default true * @default true
*/ */
reportUsage: z.boolean().optional().default(true), reportUsage: z.boolean().optional(),
/** /**
* Customize the default `requests`-based rate-limiting for this tool. * Customize the default `requests`-based rate-limiting for this tool.
@ -177,7 +177,7 @@ export const toolConfigSchema = z
* *
* @default true * @default true
*/ */
inputSchemaAdditionalProperties: z.boolean().optional().default(true), inputSchemaAdditionalProperties: z.boolean().optional(),
/** /**
* Whether to allow additional properties in the tool's output schema. * Whether to allow additional properties in the tool's output schema.
@ -189,7 +189,7 @@ export const toolConfigSchema = z
* *
* @default true * @default true
*/ */
outputSchemaAdditionalProperties: z.boolean().optional().default(true), outputSchemaAdditionalProperties: z.boolean().optional(),
/** /**
* Allows you to override this tool's behavior or disable it entirely for * Allows you to override this tool's behavior or disable it entirely for