MCPcopy Index your code
hub / github.com/coder/coder / injectTools

Method injectTools

aibridge/intercept/messages/base.go:134–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132}
133
134func (i *interceptionBase) injectTools() {
135 if i.mcpProxy == nil || !i.hasInjectableTools() {
136 return
137 }
138
139 i.disableParallelToolCalls()
140
141 // Inject tools.
142 var injectedTools []anthropic.ToolUnionParam
143 for _, tool := range i.mcpProxy.ListTools() {
144 injectedTools = append(injectedTools, anthropic.ToolUnionParam{
145 OfTool: &anthropic.ToolParam{
146 InputSchema: anthropic.ToolInputSchemaParam{
147 Properties: tool.Params,
148 Required: tool.Required,
149 },
150 Name: tool.ID,
151 Description: anthropic.String(tool.Description),
152 Type: anthropic.ToolTypeCustom,
153 },
154 })
155 }
156
157 // Prepend the injected tools in order to maintain any configured cache breakpoints.
158 // The order of injected tools is expected to be stable, and therefore will not cause
159 // any cache invalidation when prepended.
160 updated, err := i.reqPayload.injectTools(injectedTools)
161 if err != nil {
162 i.logger.Warn(context.Background(), "failed to set inject tools in request payload", slog.Error(err))
163 return
164 }
165 i.reqPayload = updated
166}
167
168func (i *interceptionBase) disableParallelToolCalls() {
169 // Note: Parallel tool calls are disabled to avoid tool_use/tool_result block mismatches.

Callers 5

ProcessRequestMethod · 0.45
ProcessRequestMethod · 0.45

Calls 5

hasInjectableToolsMethod · 0.95
ListToolsMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45