pull/715/head
Travis Fischer 2025-06-11 15:50:30 +07:00
rodzic 9de0192922
commit 4ebfcd35d5
6 zmienionych plików z 112 dodań i 8 usunięć

Wyświetl plik

@ -246,6 +246,10 @@ et est aut quod aut provident voluptas autem voluptas",
}
`;
exports[`OpenAPI kitchen echo tool with empty body > 9.0: POST @dev/test-everything-openapi/echo 1`] = `{}`;
exports[`OpenAPI kitchen echo tool with empty body > 9.1: POST @dev/test-everything-openapi/echo 1`] = `{}`;
exports[`OpenAPI kitchen sink pure tool > 7.0: POST @dev/test-everything-openapi/pure 1`] = `
{
"foo": "bar",
@ -259,3 +263,17 @@ exports[`OpenAPI kitchen sink pure tool > 7.1: POST @dev/test-everything-openapi
"nala": "kitten",
}
`;
exports[`OpenAPI kitchen sink unpure_marked_pure tool > 10.0: POST @dev/test-everything-openapi/unpure_marked_pure 1`] = `
{
"nala": "cat",
"now": 1749631781793,
}
`;
exports[`OpenAPI kitchen sink unpure_marked_pure tool > 10.1: POST @dev/test-everything-openapi/unpure_marked_pure 1`] = `
{
"nala": "cat",
"now": 1749631781793,
}
`;

Wyświetl plik

@ -1,3 +1,5 @@
import { expect } from 'vitest'
export type E2ETestFixture = {
path: string
@ -554,5 +556,83 @@ export const fixtureSuites: E2ETestFixtureSuite[] = [
}
}
]
},
{
title: 'OpenAPI kitchen sink disabled tool',
fixtures: [
{
path: '@dev/test-everything-openapi/disabled_tool',
request: {
method: 'POST'
},
response: {
status: 404
}
}
]
},
{
title: 'OpenAPI kitchen echo tool with empty body',
compareResponseBodies: true,
fixtures: [
{
path: '@dev/test-everything-openapi/echo',
request: {
method: 'POST'
},
response: {
body: {}
}
},
{
path: '@dev/test-everything-openapi/echo',
request: {
method: 'POST',
json: {}
},
response: {
body: {}
}
}
]
},
{
title: 'OpenAPI kitchen sink unpure_marked_pure tool',
compareResponseBodies: true,
fixtures: [
{
path: '@dev/test-everything-openapi/unpure_marked_pure',
request: {
method: 'POST',
json: {
nala: 'cat'
}
},
response: {
validate: (body) => {
expect(body?.nala).toEqual('cat')
expect(typeof body.now).toBe('number')
expect(body.now).toBeGreaterThan(0)
}
}
},
{
path: '@dev/test-everything-openapi/unpure_marked_pure',
request: {
method: 'POST',
json: {
nala: 'cat'
}
},
response: {
headers: {
'cf-cache-status': 'HIT'
}
}
// compareResponseBodies should result in the same cached response body,
// even though the origin would return a different `now` value if it
// weren't marked `pure`.
}
]
}
]

Wyświetl plik

@ -49,7 +49,6 @@ export const fixtureSuites: MCPE2ETestFixtureSuite[] = [
{
title: 'Basic MCP => OpenAPI get_post success',
path: '@dev/test-basic-openapi/mcp',
// debug: true,
fixtures: [
{
request: {

Wyświetl plik

@ -43,10 +43,16 @@ export async function getToolArgsFromRequest(
return incomingRequestArgs
} else if (request.method === 'POST') {
const incomingRequestArgsRaw = (await request.clone().json()) as Record<
string,
any
>
let incomingRequestArgsRaw: unknown = {}
// TODO: verify content-type of request is application/json
try {
incomingRequestArgsRaw = (await request.json()) as Record<string, any>
} catch {
// If the request body is not JSON or malformed, ignore it for now.
// TODO: need to improve on this logic.
}
// TODO: Proper support for empty params with POST requests
assert(incomingRequestArgsRaw, 400, 'Invalid empty request body')

Wyświetl plik

@ -126,11 +126,11 @@ export async function resolveOriginToolCall({
if (pricingPlanToolOverride.enabled !== undefined) {
assert(
pricingPlanToolOverride.enabled,
403,
toolConfig.enabled ? 403 : 404,
`Tool "${tool.name}" is disabled for pricing plan "${pricingPlan.slug}"`
)
} else {
assert(toolConfig.enabled, 403, `Tool "${tool.name}" is disabled`)
assert(toolConfig.enabled, 404, `Tool "${tool.name}" is disabled`)
}
if (pricingPlanToolOverride.reportUsage !== undefined) {
@ -142,7 +142,7 @@ export async function resolveOriginToolCall({
rateLimit = pricingPlanToolOverride.rateLimit as RateLimit
}
} else {
assert(toolConfig.enabled, 403, `Tool "${tool.name}" is disabled`)
assert(toolConfig.enabled, 404, `Tool "${tool.name}" is disabled`)
}
} else {
// Default to not caching any responses.

Wyświetl plik

@ -34,6 +34,7 @@
- oauth flow
- https://docs.scalekit.com/guides/mcp/oauth
- openapi-kitchen-sink
- add more test cases to e2e tests
- mcp-kitchen-sink
- how to handle binary bodies and responses?
- improve logger vs console for non-hono path and util methods