From 289eb8c801d77b82edc1f9cb801758737d493846 Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Mon, 8 Dec 2025 11:02:42 +0100 Subject: [PATCH] fix: include empty properties in get_me schema for OpenAI compatibility OpenAI strict mode requires the `properties` field to be present in object schemas, even when empty. The jsonschema library uses omitempty which causes empty maps to be omitted during JSON serialization. This change uses json.RawMessage to bypass the library's serialization and explicitly include `"properties": {}` in the output. Fixes #1548 --- pkg/github/__toolsnaps__/get_me.snap | 3 ++- pkg/github/context_tools.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/github/__toolsnaps__/get_me.snap b/pkg/github/__toolsnaps__/get_me.snap index f62131f7d..e6d02929f 100644 --- a/pkg/github/__toolsnaps__/get_me.snap +++ b/pkg/github/__toolsnaps__/get_me.snap @@ -5,7 +5,8 @@ }, "description": "Get details of the authenticated GitHub user. Use this when a request is about the user's own profile for GitHub. Or when information is missing to build other tool calls.", "inputSchema": { - "type": "object" + "type": "object", + "properties": {} }, "name": "get_me" } \ No newline at end of file diff --git a/pkg/github/context_tools.go b/pkg/github/context_tools.go index 36a682f62..3fe622379 100644 --- a/pkg/github/context_tools.go +++ b/pkg/github/context_tools.go @@ -2,6 +2,7 @@ package github import ( "context" + "encoding/json" "time" ghErrors "github.com/github/github-mcp-server/pkg/errors" @@ -43,9 +44,9 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"), ReadOnlyHint: true, }, - InputSchema: &jsonschema.Schema{ - Type: "object", - }, + // Use json.RawMessage to ensure "properties" is included even when empty. + // OpenAI strict mode requires the properties field to be present. + InputSchema: json.RawMessage(`{"type":"object","properties":{}}`), }, mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) { client, err := getClient(ctx)