Skip to content

MCP extract_facts entity_hints array schema is missing items #806

@flamingice

Description

@flamingice

Summary

The MCP schema for extract_facts declares entity_hints as an array but does not declare an items schema. Strict OpenAI-compatible tool validators reject this before the model runs.

Location

src/core/operations.ts:

entity_hints: {
  type: 'array',
  description: 'Existing canonical entity slugs the agent has already resolved. Helps the extractor pick the right slug.'
}

src/mcp/tool-defs.ts only emits items when the operation param has v.items, so the generated MCP tool schema also lacks items.

Observed error

When GBrain is exposed as an MCP server to Hermes using an OpenAI Codex backend, the whole request is rejected with:

HTTP 400: Invalid schema for function 'mcp_gbrain_extract_facts':
In context=('properties', 'entity_hints'), array schema missing items.
param: tools[10].parameters
code: invalid_function_parameters

Reproduction

  1. Build MCP tool definitions from operations.
  2. Inspect extract_facts.inputSchema.properties.entity_hints.
  3. It is emitted as:
{
  "type": "array",
  "description": "Existing canonical entity slugs the agent has already resolved. Helps the extractor pick the right slug."
}

Expected behavior

Array parameters should include an items schema. For this field, the values are canonical entity slug strings, so the schema should be:

entity_hints: {
  type: 'array',
  items: { type: 'string' },
  description: 'Existing canonical entity slugs the agent has already resolved. Helps the extractor pick the right slug.'
}

Suggested regression check

Add a test that every MCP-facing operation parameter with type: 'array' produces a tool schema containing items. This prevents future strict tool validators from rejecting the whole MCP tool list because of one malformed array parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions