Skip to content

Commit 82c4930

Browse files
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
1 parent f197a9f commit 82c4930

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/github/__toolsnaps__/get_me.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
},
66
"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.",
77
"inputSchema": {
8-
"type": "object"
8+
"type": "object",
9+
"properties": {}
910
},
1011
"name": "get_me"
1112
}

pkg/github/context_tools.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"context"
5+
"encoding/json"
56
"time"
67

78
ghErrors "github.com/github/github-mcp-server/pkg/errors"
@@ -43,9 +44,9 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
4344
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
4445
ReadOnlyHint: true,
4546
},
46-
InputSchema: &jsonschema.Schema{
47-
Type: "object",
48-
},
47+
// Use json.RawMessage to ensure "properties" is included even when empty.
48+
// OpenAI strict mode requires the properties field to be present.
49+
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
4950
},
5051
mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
5152
client, err := getClient(ctx)

0 commit comments

Comments
 (0)