koala73/worldmonitor · error · SafeWebMcpError

query must be a string.

Error message

query must be a string.

What it means

SafeWebMcpError thrown by the search_dashboard tool's execute guard when the query argument is not a string (missing, number, object, etc.). It is a manual input-shape check that backstops the JSON schema, classed as a validation error for the MCP client.

Source

Thrown at src/services/webmcp.ts:2462

            description: 'Maximum number of concise results to return.',
            minimum: 1,
            maximum: MAX_SEARCH_RESULTS,
            default: DEFAULT_SEARCH_RESULTS,
          },
        },
        required: ['query'],
        additionalProperties: false,
      },
      annotations: { readOnlyHint: true, untrustedContentHint: true },
      execute: withInvocationLogging(WEBMCP_SPA_TOOL.searchDashboard, async (args, extra) => {
        if (!hasOnlyOwnKeys(args, ['query', 'scope', 'limit'])) {
          throw new SafeWebMcpError(
            'search_dashboard accepts only query, scope, and limit.',
            'validation',
          );
        }
        if (typeof args.query !== 'string') {
          throw new SafeWebMcpError('query must be a string.', 'validation');
        }
        if (args.query.length > MAX_SEARCH_QUERY_CHARS) {
          throw new SafeWebMcpError(
            `query must be at most ${MAX_SEARCH_QUERY_CHARS} characters.`,
            'validation',
          );
        }
        const query = args.query.trim();
        if (!query) throw new SafeWebMcpError('query must not be empty.', 'validation');

        const scope = args.scope === undefined ? 'all' : args.scope;
        if (typeof scope !== 'string' || !DASHBOARD_SEARCH_SCOPES.has(scope as DashboardSearchScope)) {
          throw new SafeWebMcpError(
            'scope must be one of: all, signals, map, panels, actions.',
            'validation',
          );
        }
        const limit = args.limit === undefined ? DEFAULT_SEARCH_RESULTS : args.limit;

View on GitHub (pinned to 9361220cc0)

Solutions

  1. Send query as a JSON string in the tool arguments
  2. Fix the calling MCP client's argument serialization
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/services/webmcp.ts:759 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@9361220cc0 (2026-08-21). Data as JSON: /api/errors/0a616860cb5af92b. Report an issue: GitHub.