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

Method Run

coderd/x/chatd/mcpclient/mcpclient.go:586–623  ·  view source on GitHub ↗
(
	ctx context.Context,
	params fantasy.ToolCall,
)

Source from the content-addressed store, hash-verified

584}
585
586func (t *mcpToolWrapper) Run(
587 ctx context.Context,
588 params fantasy.ToolCall,
589) (fantasy.ToolResponse, error) {
590 input := params.Input
591 if t.modelIntent {
592 input = unwrapModelIntent(input)
593 }
594
595 var args map[string]any
596 if input != "" {
597 if err := json.Unmarshal(
598 []byte(input), &args,
599 ); err != nil {
600 return fantasy.NewTextErrorResponse(
601 "invalid JSON input: " + err.Error(),
602 ), nil
603 }
604 }
605
606 callCtx, cancel := context.WithTimeout(ctx, toolCallTimeout)
607 defer cancel()
608
609 result, err := t.client.CallTool(
610 callCtx,
611 mcp.CallToolRequest{
612 Params: mcp.CallToolParams{
613 Name: t.originalName,
614 Arguments: args,
615 },
616 },
617 )
618 if err != nil {
619 return fantasy.NewTextErrorResponse(err.Error()), nil
620 }
621
622 return convertCallResult(result), nil
623}
624
625func (t *mcpToolWrapper) ProviderOptions() fantasy.ProviderOptions {
626 return t.providerOptions

Callers

nothing calls this directly

Calls 5

unwrapModelIntentFunction · 0.85
convertCallResultFunction · 0.85
CallToolMethod · 0.65
UnmarshalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected