Skip to content

[Request]: give @jimhoyd/urlcode-mcp handlers request context (env bindings, request id) #678

Closed

Description

@jimhoyd

Problem or use case

Tool, resource and prompt handlers run through loadExtensionHooks, which calls the export as fn(input) (dist/extensions.js), so a handler only receives the validated arguments. A real tool server also needs:

  • Route env bindings. urlcode-ai's tools read MCP_ENABLED_SKILLS (the skills visible to skills_list/skills_get), FEEDBACK_TABLE_NAME and AWS_REGION. These are policy-granted, revision-pinned route bindings on a function route. A handler could read process.env, but that skips the operator-grant model the function route enforces.
  • A request id, to correlate per-tool usage and audit events with the request log. Today onToolError is the only operator hook, and it only fires on failure, so success, latency and tool-error telemetry isn't possible.
  • Env-dependent tool schemas. skills_get.id is an enum of the enabled skills, which comes from an env binding. In YAML it would have to be copied by hand and kept in sync with the env value.

Proposed behavior and alternatives

  • Call tool, resource and prompt handlers as handler(args, context), where context has at least the mount's granted env, a requestId, and the server/tool names. Keep the first argument unchanged so existing handlers keep working.
  • Add an onToolCall({server, tool, kind, outcome, durationMs, requestId}) host callback next to onToolError, so operators can emit usage events without wrapping each handler.
  • Allow env bindings on an extension: mcp route (or on the server config) that are granted by the operator policy the same way function-route bindings are.

Activity

  1. added
    enhancement
    extension
    needs-decision
    ai-first
    and removed
    needs-decision
    on Sep 24, 2026
  2. added a commit that references this issue on Sep 24, 2026
    961b9c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-firstenhancementextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions