Skip to content

Context7 MCP not working (Invalid schema for function 'context7_get-library-docs') #250

Closed
grunt-it/gruntcode
#22

Description

@chipit24

I tried setting up the Context7 MCP but I kept getting this error:

Image

Here's the output of running opencode --print-logs run Hello:

INFO  2025-06-20T14:23:18 +24ms service=default version=0.1.109 args=--print-logs,run,Hello opencode
INFO  2025-06-20T14:23:18 +0ms service=app cwd=/Users/robertkomaromi/Code/calendar-sync/calendarsync-nextjs creating
INFO  2025-06-20T14:23:18 +1ms service=app git=/Users/robertkomaromi/Code/calendar-sync/calendarsync-nextjs git
INFO  2025-06-20T14:23:18 +1ms service=app name=share registering service
INFO  2025-06-20T14:23:18 +0ms service=bus type=storage.write subscribing
INFO  2025-06-20T14:23:18 +0ms service=app name=bus registering service
INFO  2025-06-20T14:23:18 +1ms service=session id=ses_872470a4affe14cafbc2a816f0 version=0.1.109 title=New Session - 2025-06-20T14:23:18.453Z time=[object Object] created
INFO  2025-06-20T14:23:18 +0ms service=app name=session registering service
INFO  2025-06-20T14:23:18 +0ms service=app name=storage registering service
INFO  2025-06-20T14:23:18 +0ms service=storage path=/Users/robertkomaromi/.local/share/opencode/project/-Users-robertkomaromi-Code-calendar-sync-calendarsync-nextjs/storage init
INFO  2025-06-20T14:23:18 +0ms service=bus type=storage.write publishing
INFO  2025-06-20T14:23:18 +0ms service=app name=config registering service
INFO  2025-06-20T14:23:18 +1ms service=config $schema=https://opencode.ai/config.json theme=opencode autoshare=false autoupdate=true model=openai/gpt-4.1-mini mcp=[object Object] loaded
INFO  2025-06-20T14:23:18 +0ms service=bus type=session.updated publishing

█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

>  Hello

@  openai/gpt-4.1-mini

INFO  2025-06-20T14:23:18 +1ms service=bus type=message.part.updated subscribing
INFO  2025-06-20T14:23:18 +0ms service=session session=ses_872470a4affe14cafbc2a816f0 chatting
INFO  2025-06-20T14:23:18 +0ms service=app name=provider registering service
INFO  2025-06-20T14:23:18 +1ms service=models.dev refreshing
INFO  2025-06-20T14:23:18 +0ms service=provider init
INFO  2025-06-20T14:23:18 +0ms service=provider providerID=openai found
INFO  2025-06-20T14:23:18 +0ms service=provider providerID=openai modelID=gpt-4.1-mini getModel
INFO  2025-06-20T14:23:18 +1ms service=provider status=started providerID=openai getSDK
INFO  2025-06-20T14:23:18 +9ms service=provider status=completed duration=9 providerID=openai getSDK
INFO  2025-06-20T14:23:18 +0ms service=provider providerID=openai modelID=gpt-4.1-mini found
INFO  2025-06-20T14:23:18 +1ms service=session sessionID=ses_872470a4affe14cafbc2a816f0 locking
INFO  2025-06-20T14:23:18 +4ms service=bus type=storage.write publishing
INFO  2025-06-20T14:23:18 +0ms service=bus type=message.updated publishing
INFO  2025-06-20T14:23:18 +1ms service=bus type=storage.write publishing
INFO  2025-06-20T14:23:18 +0ms service=bus type=message.updated publishing
INFO  2025-06-20T14:23:18 +0ms service=app name=mcp registering service
ERROR 2025-06-20T14:23:18 +457ms service=session error=AI_APICallError: Invalid schema for function 'context7_get-library-docs': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'topic'. callback error
INFO  2025-06-20T14:23:18 +0ms service=bus type=session.error publishing
INFO  2025-06-20T14:23:18 +2ms service=session session=ses_872470a4affe14cafbc2a816f0 type=error part
INFO  2025-06-20T14:23:18 +0ms service=session session=ses_872470a4affe14cafbc2a816f0 type=error unhandled
INFO  2025-06-20T14:23:18 +3ms service=bus type=storage.write publishing
INFO  2025-06-20T14:23:18 +0ms service=bus type=message.updated publishing
INFO  2025-06-20T14:23:18 +0ms service=session sessionID=ses_872470a4affe14cafbc2a816f0 unlocking
INFO  2025-06-20T14:23:18 +0ms service=app name=session shutdown
INFO  2025-06-20T14:23:18 +0ms service=app name=mcp shutdown
INFO  2025-06-20T14:23:19 +277ms service=bus type=storage.write publishing
INFO  2025-06-20T14:23:19 +0ms service=bus type=session.updated publishing

And here's my opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "theme": "opencode",
  "model": "openai/gpt-4.1-mini",
  "autoshare": false,
  "autoupdate": true,
  "mcp": {
    "context7": {
      "type": "remote",
      "url": "https://mcp.context7.com/sse"
    }
  }
}

I tried setting it up locally as well, but got the same error.

"context7": {
  "type": "local",
  "command": ["npx", "-y", "@upstash/context7-mcp"]
}

I have this same setup for Claude Code and it appears to work there. Is there something I'm missing in my config for opencode?

Activity

  1. chipit24 commented on Jun 20, 2025

    @chipit24
    Author

    Oh, huh, I get the same error regardless of which MCP tool I have set up 🤔 so it's probably something wrong with how I've specified my config. If I just delete the entire mcp block or leave it empty ("mcp": {}), it works. But if I try any other tool I get the same AI_APICallError: Invalid schema for function error (just with a different tool name, like postgres_list_objects when I tried with postgres-mcp).

  2. self-assigned this
    on Jun 20, 2025
  3. khalido commented on Jun 22, 2025

    @khalido

    Getting the same error:

    Image

    I used this config:

    {
      "$schema": "https://opencode.ai/config.json",
      "autoupdate": true,
      "mcp": {
        "context7": {
          "type": "remote",
          "url": "https://mcp.context7.com/sse"
        }
      }
    }
    

    Additional request - can you pls add a remote MCP sever config like context7 to the mcp docs and a way to list and and test all configured MCP servers?

    3 Remote MCP servers configured..
    1. context7 - working / error 
    2. etc
    
  4. khalido commented on Jun 24, 2025

    @khalido

    Thanks for the furious development - I'm still getting the same error with the context7 MCP? I nuked opencode and reinstalled by brew install sst/tap/opencode just now to v0.1.130.

  5. totalolage commented on Jun 27, 2025

    @totalolage

    I am seeing the exact same issue on v0.1.150

    ❯ opencode --print-logs --model openai/o4-mini run 'Say "Hi"'
    INFO  2025-06-27T08:39:59 +28ms service=default version=0.1.150 args=--print-logs,--model,openai/o4-mini,run,Say "
    Hi" opencode
    INFO  2025-06-27T08:39:59 +0ms service=app cwd=/Users/c_fkalny/.config/opencode creating
    INFO  2025-06-27T08:39:59 +3ms service=app git
    INFO  2025-06-27T08:39:59 +1ms service=app name=share registering service
    INFO  2025-06-27T08:39:59 +0ms service=bus type=storage.write subscribing
    INFO  2025-06-27T08:39:59 +0ms service=app name=bus registering service
    INFO  2025-06-27T08:39:59 +1ms service=session id=ses_84f74d87dffeMJhtqCY8p0DCO2 version=0.1.150 title=New Session
     - 2025-06-27T08:39:59.107Z time=[object Object] created
    INFO  2025-06-27T08:39:59 +0ms service=app name=session registering service
    INFO  2025-06-27T08:39:59 +0ms service=app name=storage registering service
    INFO  2025-06-27T08:39:59 +0ms service=storage path=/Users/c_fkalny/.local/share/opencode/project/global/storage i
    nit
    INFO  2025-06-27T08:39:59 +0ms service=bus type=storage.write publishing
    INFO  2025-06-27T08:39:59 +0ms service=app name=config registering service
    INFO  2025-06-27T08:39:59 +1ms service=config $schema=https://opencode.ai/config.json theme=system autoshare=false
     autoupdate=true mcp=[object Object] loaded
    INFO  2025-06-27T08:39:59 +0ms service=bus type=session.updated publishing
    
    █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
    █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
    ▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀
    
    >  Say "Hi"
    
    @  openai/o4-mini
    
    INFO  2025-06-27T08:39:59 +1ms service=bus type=message.part.updated subscribing
    INFO  2025-06-27T08:39:59 +1ms service=session session=ses_84f74d87dffeMJhtqCY8p0DCO2 chatting
    INFO  2025-06-27T08:39:59 +0ms service=app name=provider registering service
    INFO  2025-06-27T08:39:59 +1ms service=models.dev refreshing
    INFO  2025-06-27T08:39:59 +0ms service=provider init
    INFO  2025-06-27T08:39:59 +2ms service=provider providerID=anthropic found
    INFO  2025-06-27T08:39:59 +0ms service=provider providerID=openai found
    INFO  2025-06-27T08:39:59 +0ms service=provider providerID=openai modelID=o4-mini getModel
    INFO  2025-06-27T08:39:59 +0ms service=provider status=started providerID=openai getSDK
    INFO  2025-06-27T08:39:59 +23ms service=provider status=completed duration=23 providerID=openai getSDK
    INFO  2025-06-27T08:39:59 +0ms service=provider providerID=openai modelID=o4-mini found
    INFO  2025-06-27T08:39:59 +0ms service=session sessionID=ses_84f74d87dffeMJhtqCY8p0DCO2 locking
    INFO  2025-06-27T08:39:59 +5ms service=bus type=storage.write publishing
    INFO  2025-06-27T08:39:59 +0ms service=bus type=message.updated publishing
    INFO  2025-06-27T08:39:59 +4ms service=bus type=storage.write publishing
    INFO  2025-06-27T08:39:59 +0ms service=bus type=message.updated publishing
    INFO  2025-06-27T08:39:59 +0ms service=app name=mcp registering service
    INFO  2025-06-27T08:39:59 +1ms service=mcp key=documentation type=remote found
    ERROR 2025-06-27T08:40:00 +1324ms service=session error=AI_APICallError: Invalid schema for function 'documentatio
    n_get-library-docs': In context=(), 'required' is required to be supplied and to be an array including every key i
    n properties. Missing 'topic'. callback error
    INFO  2025-06-27T08:40:00 +0ms service=bus type=session.error publishing
    INFO  2025-06-27T08:40:00 +1ms service=session session=ses_84f74d87dffeMJhtqCY8p0DCO2 type=error part
    INFO  2025-06-27T08:40:00 +0ms service=session session=ses_84f74d87dffeMJhtqCY8p0DCO2 type=error unhandled
    INFO  2025-06-27T08:40:00 +3ms service=bus type=storage.write publishing
    INFO  2025-06-27T08:40:00 +0ms service=bus type=message.updated publishing
    INFO  2025-06-27T08:40:00 +0ms service=session sessionID=ses_84f74d87dffeMJhtqCY8p0DCO2 unlocking
    INFO  2025-06-27T08:40:00 +1ms service=app name=session shutdown
    INFO  2025-06-27T08:40:00 +0ms service=app name=mcp shutdown
    

    config:

    {
      "$schema": "https://opencode.ai/config.json",
      "theme": "system",
      "autoshare": false,
      "autoupdate": true,
      "mcp": {
        "documentation": {
          "type": "remote",
          "url": "https://mcp.context7.com/sse"
        }
      }
    }
    
  6. dormeiri commented on Jun 28, 2025

    @dormeiri

    Same issue with Context7 and Sequential Thinking in version 0.1.160

    INFO  2025-06-28T18:22:40 +20ms service=default version=0.1.160 args=run,use context7, what's the most recent update in react?,--print-logs opencode
    INFO  2025-06-28T18:22:40 +1ms service=app cwd=*** creating
    INFO  2025-06-28T18:22:40 +1ms service=app git=*** git
    INFO  2025-06-28T18:22:40 +1ms service=bus type=storage.write subscribing
    INFO  2025-06-28T18:22:40 +0ms service=app name=bus registering service
    INFO  2025-06-28T18:22:40 +0ms service=format init
    INFO  2025-06-28T18:22:40 +0ms service=bus type=file.edited subscribing
    INFO  2025-06-28T18:22:40 +0ms service=config.hooks init
    INFO  2025-06-28T18:22:40 +0ms service=bus type=file.edited subscribing
    INFO  2025-06-28T18:22:40 +0ms service=bus type=session.idle subscribing
    INFO  2025-06-28T18:22:40 +0ms service=session id=ses_848390330ffe5j0Xf3uLQjG47f version=0.1.160 title=New Session - 2025-06-28T18:22:40.847Z time=[object Object] created
    INFO  2025-06-28T18:22:40 +0ms service=app name=session registering service
    INFO  2025-06-28T18:22:40 +0ms service=app name=storage registering service
    INFO  2025-06-28T18:22:40 +1ms service=storage path=***/storage init
    INFO  2025-06-28T18:22:40 +0ms service=bus type=storage.write publishing
    INFO  2025-06-28T18:22:40 +0ms service=app name=config registering service
    INFO  2025-06-28T18:22:40 +1ms service=config $schema=https://opencode.ai/config.json theme=catppuccin autoshare=false autoupdate=true disabled_providers=amazon-bedrock model=openai/gpt-4.1-mini mcp=[object Object] loaded
    INFO  2025-06-28T18:22:40 +0ms service=bus type=session.updated publishing
    
    █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
    █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
    ▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀
    
    >  use context7, what's the most recent update in react?
    
    @  openai/gpt-4.1-mini
    
    INFO  2025-06-28T18:22:40 +1ms service=bus type=message.part.updated subscribing
    INFO  2025-06-28T18:22:40 +0ms service=session session=ses_848390330ffe5j0Xf3uLQjG47f chatting
    INFO  2025-06-28T18:22:40 +0ms service=app name=provider registering service
    INFO  2025-06-28T18:22:40 +1ms service=models.dev refreshing
    INFO  2025-06-28T18:22:40 +0ms service=provider init
    INFO  2025-06-28T18:22:40 +2ms service=provider providerID=openai found
    INFO  2025-06-28T18:22:40 +0ms service=provider providerID=openai modelID=gpt-4.1-mini getModel
    INFO  2025-06-28T18:22:40 +0ms service=provider status=started providerID=openai getSDK
    INFO  2025-06-28T18:22:40 +11ms service=provider status=completed duration=11 providerID=openai getSDK
    INFO  2025-06-28T18:22:40 +0ms service=provider providerID=openai modelID=gpt-4.1-mini found
    INFO  2025-06-28T18:22:40 +0ms service=session sessionID=ses_848390330ffe5j0Xf3uLQjG47f locking
    INFO  2025-06-28T18:22:40 +3ms service=bus type=storage.write publishing
    INFO  2025-06-28T18:22:40 +0ms service=bus type=message.updated publishing
    INFO  2025-06-28T18:22:40 +1ms service=bus type=storage.write publishing
    INFO  2025-06-28T18:22:40 +0ms service=bus type=message.updated publishing
    INFO  2025-06-28T18:22:40 +1ms service=app name=mcp registering service
    INFO  2025-06-28T18:22:40 +0ms service=mcp key=thinking type=local found
    INFO  2025-06-28T18:22:41 +136ms service=bus type=session.error publishing
    INFO  2025-06-28T18:22:41 +0ms service=mcp key=context7 type=remote found
    INFO  2025-06-28T18:22:41 +611ms service=bus type=storage.write publishing
    INFO  2025-06-28T18:22:41 +0ms service=bus type=session.updated publishing
    ERROR 2025-06-28T18:22:42 +960ms service=session error=AI_APICallError: Invalid schema for function 'context7_get-library-docs': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'topic'. callback error
    INFO  2025-06-28T18:22:42 +1ms service=bus type=session.error publishing
    INFO  2025-06-28T18:22:42 +1ms service=session session=ses_848390330ffe5j0Xf3uLQjG47f type=error part
    INFO  2025-06-28T18:22:42 +0ms service=session session=ses_848390330ffe5j0Xf3uLQjG47f type=error unhandled
    INFO  2025-06-28T18:22:42 +2ms service=bus type=storage.write publishing
    INFO  2025-06-28T18:22:42 +0ms service=bus type=message.updated publishing
    INFO  2025-06-28T18:22:42 +0ms service=session sessionID=ses_848390330ffe5j0Xf3uLQjG47f unlocking
    INFO  2025-06-28T18:22:42 +1ms service=bus type=session.idle publishing
    INFO  2025-06-28T18:22:42 +0ms service=app name=session shutdown
    INFO  2025-06-28T18:22:42 +0ms service=app name=mcp shutdown
    
        "context7": {
          "type": "remote",
          "url": "https://mcp.context7.com/sse"
        }
    

    Also installing the MCP locally fails

  7. arnold-c commented on Jul 2, 2025

    @arnold-c

    Using opencode version 0.1.173, the local Context7 MCP seems to be working with the following config.

    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "localmcp": {
          "type": "local",
          "command": [
            "npx",
            "-y",
            "@upstash/context7-mcp"
          ],
          "enabled": true
        }
      }
  8. grota commented on Jul 2, 2025

    @grota
    Contributor

    I tried the exact same conf with 0.1.176 and it does not work

  9. thdxr commented on Jul 2, 2025

    @thdxr
    Member

    this is because openai models do not allow optional fields in their tool definitions. i need to think about how to properly address this - we patch this for our own tools but not for mcp ones

  10. grota commented on Jul 2, 2025

    @grota
    Contributor

    I know I'm not contributing much new information here, but, yeah, from a quick look at https://platform.openai.com/docs/guides/function-calling#strict-mode, it seems that when strict mode is enabled, all parameters (both required and optional) must be included in the "required": [...] schema field. The only way to make a parameter "optional" is to add null to its type.

  11. thdxr commented on Jul 25, 2025

    @thdxr
    Member

    fixed in latest

  12. added a commit that references this issue on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions