Documentation
¶
Overview ¶
Package toolnamespace bridges Responses API `namespace` tools to protocols that only know flat function tools (OpenAI Chat, Anthropic).
A Responses client such as Codex groups MCP tools under a namespace:
{"type":"namespace","name":"mcp__linear__","tools":[{"type":"function","name":"get_issue",...}]}
and sends a call back as {"type":"function_call","namespace":"mcp__linear__","name":"get_issue"}. Flat upstreams have no such grouping, so the request side expands each namespace member into a function named FlatName(namespace, name), and the response side uses an Index built from the same request to split that name back into namespace and name.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlatName ¶
FlatName is the function name a namespace member gets on a flat upstream. Codex namespaces MCP servers as `mcp__<server>__`, so the usual result is the familiar `mcp__<server>__<tool>`; a namespace without a trailing underscore gets a `__` separator.
func Functions ¶
func Functions(tools []responses.ToolUnionParam) []responses.FunctionToolParam
Functions returns the function tools of a Responses tool list in request order, with every namespace member expanded under its flat name. Whatever cannot be offered upstream is logged rather than dropped silently: a namespace member lost to a name clash or because it is not a function is a warning, a top-level tool type with no flat equivalent (web_search, custom and the like, which a flat upstream never had) is debug output, since clients such as Codex send those on every request.
Types ¶
type Index ¶
Index maps a flattened function name to the namespace member it came from. A nil Index restores nothing.
func IndexOf ¶
func IndexOf(tools []responses.ToolUnionParam) Index
IndexOf returns the Index for a Responses request's tools: one entry per function inside a namespace. It is nil when the request has none. It makes the same decisions as Functions, so the names it knows are exactly the ones the upstream was offered.