Repository navigation
Context7 MCP not working (Invalid schema for function 'context7_get-library-docs') #250
Copy link
Copy link
Closed
grunt-it/gruntcode
#22Description
I tried setting up the Context7 MCP but I kept getting this error:
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 publishingAnd 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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

Activity
chipit24 commentedon Jun 20, 2025
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
mcpblock or leave it empty ("mcp": {}), it works. But if I try any other tool I get the sameAI_APICallError: Invalid schema for functionerror (just with a different tool name, likepostgres_list_objectswhen I tried withpostgres-mcp).khalido commentedon Jun 22, 2025
Getting the same error:
I used this config:
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?
khalido commentedon Jun 24, 2025
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/opencodejust now tov0.1.130.totalolage commentedon Jun 27, 2025
I am seeing the exact same issue on
v0.1.150config:
dormeiri commentedon Jun 28, 2025
Same issue with Context7 and Sequential Thinking in version 0.1.160
Also installing the MCP locally fails
arnold-c commentedon Jul 2, 2025
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 } }grota commentedon Jul 2, 2025
I tried the exact same conf with 0.1.176 and it does not work
thdxr commentedon Jul 2, 2025
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
grota commentedon Jul 2, 2025
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
strictmode 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 addnullto its type.thdxr commentedon Jul 25, 2025
fixed in latest
Merge pull request anomalyco#250 from OkminLee/feat/skills/ios26-thre…
Use OpenCode commands instead of templates (anomalyco#250)