Repository navigation
feat(capabilities): function discovery carries the cookbook handler example (#1106) - #1111
Merged
Merged
Conversation
…xample (#1106) `urlcode capabilities function` and MCP `get_capability` now include an `example`: the cookbook /hello/{name} route lines read verbatim from examples/cookbook/routes/code.yaml, the handler module it names read from its file, and one sentence on how args, inputs, env, secrets and requestId reach `(request, context)`. Nothing is copied: tests assert the YAML is the file's own lines, the module is the file, the handler runs, the contract names real FunctionContext members, and the example stays under 2 KiB. The packed-consumer smoke runs the handler from the installed package. The function `args` constraint now names `{secret}` references too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1106.
What changed
getCapability('function')(sourlcode capabilities function [--json]and MCPget_capability) now carries anexample:yaml: the cookbook/hello/{name}route lines exactly asexamples/cookbook/routes/code.yamlhas them (path/query{from}args, an{env}arg, a literal, a named export);module:functions/hello.mjsread from its file, with the export the route names;contract: one sentence on(request, context),context.args,context.inputs.path/query/header,context.env,context.secrets(operator-granted) andcontext.requestId, and how to copy the whole cookbook.FunctionContextmembers (a rename fails typecheck), and the example stays under a 2 KiB bound (handlerExampleMaxBytes). A missing route or file throws instead of degrading silently.argsconstraint now also names{secret}references, which the schema already accepts.get_capabilitytool description mentions the example (only mcp.ts change).capabilities function --jsonis bounded, and its handler is imported from the installed package and run.Sizes
urlcode capabilities function --json: 4,421 -> 6,032 bytesurlcode capabilities function(text): 5,978 -> 7,596 bytesEvidence
npm run typecheck,npm run verifyandnpm run test:packagepass locally (macOS). Not verified: an agent-run comparison showing reduced discovery time.🤖 Generated with Claude Code