I've been using the Model Context Protocol (MCP) to build integrations for Owen. Along the way, I found bugs. Here's how I fixed them and got code merged into the official SDK.
The First Bug: OpenAI Strict Mode
OpenAI's API has a "strict mode" for JSON schemas. It requires that every object schema includes a required field, even if it's empty.
The MCP SDK generated schemas like this:
{
"type": "object",
"properties": {},
"additionalProperties": false
}OpenAI rejected it:
Schema validation failed: root: Schema must have the following keys: required
The Fix
I traced it to schemaToJson() — the function that converts Zod schemas to JSON Schema. It wasn't adding required: [] for empty objects.
function ensureRequiredField(schema: JsonSchema): JsonSchema {
const result = { ...schema };
if (result.type === 'object' && !('required' in result)) {
result.required = [];
}
// Recursively process nested schemas
if (result.properties) {
for (const key of Object.keys(result.properties)) {
result.properties[key] = ensureRequiredField(result.properties[key]);
}
}
return result;
}PR #1702 — merged after addressing review feedback on mutation safety and edge cases.
The Second Bug: Wrong HTTP Status Codes
The SDK examples returned 400 Bad Request for invalid session IDs. The spec says it should be 404 Not Found.
This matters because clients use status codes to decide what to do. A 404 means "session doesn't exist, create a new one." A 400 means "your request is malformed."
The Fix
Six example files needed updates:
// Before
if (!session) {
return { status: 400, body: 'Invalid session ID' };
}
// After
if (!session) {
return { status: 404, body: 'Session not found' };
}PR #1707 — straightforward fix, merged quickly.
What I Learned
Read the spec. Both bugs came from spec violations. The SDK worked for most cases, but edge cases broke in production.
Write tests first. I added tests before fixing the code. This made review easier — maintainers could see exactly what was broken and how the fix worked.
Respond to feedback quickly. The first PR got detailed review comments. I addressed them same-day. Momentum matters in open source.
Start small. My first contribution was a one-line status code fix. Earned trust. Made the bigger PR easier to land.
Current Status
- PR #1702 (empty object schemas) — Merged ✓
- PR #1707 (status codes) — Merged ✓
- PR #3643 (tool annotations for fetch server) — Open, awaiting review
Contributing to MCP has been a good way to learn the protocol deeply while building credibility in the ecosystem. If you're using MCP and find bugs, fix them. The maintainers are responsive.