What variant of Codex are you using?
CLI, App, IDE Extension
What feature would you like to see?
Add granular PreToolBuild and PostToolBuild hooks that allow runtime interception and manipulation of tool definitions before they are sent to the LLM.
Current hooks and the MCP specification do not provide a way to modify the final tool payload at runtime. The proposed hooks would operate on the fully constructed tool collection immediately before model exposure.
The hooks should support:
- Adding or removing tools dynamically
- Modifying tool schemas
- Adjusting properties and required fields
- Transforming or trimming enums
- Injecting metadata or constraints
- Rewriting tool definitions before model delivery
Importantly, this should operate at a granular level, not only entire tools, but entire tool definitions in JSON.
This would enable advanced orchestration workflows that optimize prompt size, token usage, and model focus while preserving necessary capabilities.
Additional information
One practical use case is intelligent MCP tool decomposition and recomposition.
I’m building a plug-in that:
- Separates MCP tool definitions into:
- required properties
- optional properties
- enums
- Dynamically selects only the relevant parts based on the user request
- Re-composes the final tool definition before sending it to the LLM based on the user query.
For example:
- A tool may contain many optional properties that are irrelevant for most requests
- Large enum lists can significantly increase prompt size
- A timezone tool may expose hundreds of timezones even though only one or two are contextually relevant
With granular tool-build hooks, the runtime could:
- Keep the core tool intact
- Preserve only relevant optional properties
- Reduce or rewrite enums dynamically
- Strip unnecessary schema noise
- Lower token consumption
- Improve LLM focus and tool-selection quality
This becomes especially important in multi-session and multi-agent environments where tool definitions may need to be adapted dynamically per request or agent context.
Currently, neither the MCP SPEC nor the existing hook system can account for this, and the only viable workaround is implementing an external proxy layer that intercepts and rewrites tool definitions before they reach the model. While technically possible, this is cumbersome, less ergonomic, and introduces unnecessary infrastructure complexity for functionality that naturally belongs in the hook system.
What variant of Codex are you using?
CLI, App, IDE Extension
What feature would you like to see?
Add granular
PreToolBuildandPostToolBuildhooks that allow runtime interception and manipulation of tool definitions before they are sent to the LLM.Current hooks and the MCP specification do not provide a way to modify the final tool payload at runtime. The proposed hooks would operate on the fully constructed tool collection immediately before model exposure.
The hooks should support:
Importantly, this should operate at a granular level, not only entire tools, but entire tool definitions in JSON.
This would enable advanced orchestration workflows that optimize prompt size, token usage, and model focus while preserving necessary capabilities.
Additional information
One practical use case is intelligent MCP tool decomposition and recomposition.
I’m building a plug-in that:
For example:
With granular tool-build hooks, the runtime could:
This becomes especially important in multi-session and multi-agent environments where tool definitions may need to be adapted dynamically per request or agent context.
Currently, neither the MCP SPEC nor the existing hook system can account for this, and the only viable workaround is implementing an external proxy layer that intercepts and rewrites tool definitions before they reach the model. While technically possible, this is cumbersome, less ergonomic, and introduces unnecessary infrastructure complexity for functionality that naturally belongs in the hook system.