Skip to content

vMCP logs a backend tool's error text at WARN #7297

Done

Description

@alex-feel

Bug description

When a backend answers tools/call with isError: true, the vMCP backend client logs the text of the result's first content block at WARN (toolResultFromMCP, pkg/vmcp/client/client.go:2009-2013). A caller can trigger that line on every call, and a tool's error text often repeats the call's input: a query the backend could not parse, an ID it could not find, a file name. So a failed call can write the caller's input into the vMCP logs at the default level. A VirtualMCPServer's logLevel accepts only debug, so operators cannot raise the threshold to drop the line.

Steps to reproduce

Add this test to pkg/vmcp/client and run go test -run TestToolErrorLog -v ./pkg/vmcp/client/:

package client

import (
	"log/slog"
	"testing"

	"github.com/stacklok/toolhive-core/logging"
	"github.com/stacklok/toolhive-core/mcpcompat/mcp"
)

func TestToolErrorLog(t *testing.T) {
	slog.SetDefault(logging.New()) // the logger cmd/vmcp installs
	toolResultFromMCP(&mcp.CallToolResult{
		IsError: true,
		Content: []mcp.Content{mcp.NewTextContent(`cannot parse query "status:failed AND customer:4711": unexpected token`)},
	}, "search", "logs")
}

Expected behavior

The line follows docs/logging.md:22 the way code mode's failed-script line does since #7275: it is logged at Debug only, and a counter of backend isError results gives operators the signal at the default level.

Actual behavior

{"time":"2026-11-25T07:16:01Z","level":"WARN","msg":"tool returned IsError=true","tool":"search","backend":"logs","error":"cannot parse query \"status:failed AND customer:4711\": unexpected token"}

Environment (if relevant)

  • ToolHive version: v0.69.0; v0.68.0 has the same slog.Warn calls

Additional context

I have a fix that moves the line to Debug and adds a toolhive_vmcp_backend_tool_errors counter, with tests; the PR follows.

Composite tool workflows log a failed step's error text in their own lines (pkg/vmcp/composer/workflow_engine.go:518-520). This issue and the fix cover the backend client's line only.

Activity

  1. added
    needs-triage
    on Nov 25, 2026
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

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions