Skip to content

Add Exa MCP server + fix tool schema validation for Google AI Studio models#32

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-mcp-server-and-gemma-schema-support
Draft

Add Exa MCP server + fix tool schema validation for Google AI Studio models#32
Copilot wants to merge 6 commits intomainfrom
copilot/add-mcp-server-and-gemma-schema-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Google AI Studio (Gemini/Gemma via OpenRouter) rejects tool schemas where required lists property names absent from properties. Many MCP servers ship schemas with this violation, making these models unusable when any such tool is loaded.

Schema sanitization (src/llm.rs)

Added sanitize_schema() — a recursive serde_json::Value mutator applied to every tool definition in chat_with_model() before the API call:

  • Filters required[] to only retain keys that exist in properties
  • Drops required entirely if the filtered array is empty
  • Recurses into nested properties and items schemas
  • No-op for already-valid schemas → all existing models unaffected
fn sanitize_schema(schema: &mut serde_json::Value) {
    let Some(obj) = schema.as_object_mut() else { return };
    let defined_props: Option<HashSet<String>> = obj
        .get("properties").and_then(|p| p.as_object())
        .map(|p| p.keys().cloned().collect());
    if let Some(ref props) = defined_props {
        if let Some(req) = obj.get_mut("required") {
            if let Some(arr) = req.as_array_mut() {
                arr.retain(|v| v.as_str().map(|s| props.contains(s)).unwrap_or(false));
            }
        }
    }
    // remove empty required, recurse into properties + items …
}

Exa MCP server

  • setup/index.html: Added exa to MCP_CATALOG under Knowledge & Data — bridges https://mcp.exa.ai/mcp via npx mcp-remote, requires EXA_API_KEY
  • config.example.toml: Added commented [[mcp_servers]] example block for Exa

Copilot AI and others added 6 commits April 8, 2026 09:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: chinkan <16433287+chinkan@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: chinkan <16433287+chinkan@users.noreply.github.com>
…patibility

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: chinkan <16433287+chinkan@users.noreply.github.com>
Add test_sanitize_schema_recurses_into_items to verify that sanitize_schema
properly recurses into array items schemas and removes undefined required fields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: chinkan <16433287+chinkan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants