From 764883677e96056440bd1ca878b173a075ad269d Mon Sep 17 00:00:00 2001 From: chaindead Date: Sat, 28 Feb 2026 00:18:58 +0300 Subject: [PATCH] bug: fix json schema --- README.md | 11 +++++++++++ go.mod | 2 +- main.go | 5 +++++ serve.go | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eb1abfb..7e37c85 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The server is a bridge between the Telegram API and the AI assistants and is bas - [Configuration](#configuration) - [Authorization](#authorization) - [Client Configuration](#client-configuration) + - [JSON Schema Version](#json-schema-version) - [Star History](#star-history) ## What is MCP? @@ -263,6 +264,16 @@ Example of Configuring Claude Desktop to recognize the Telegram MCP server. } ``` +### JSON Schema Version + +Some MCP clients (e.g. VS Code) do not support JSON Schema Draft 2020-12 and will reject tools that use it. You can override the JSON Schema version by setting the `--schema-version` flag or the `TG_SCHEMA_VERSION` environment variable. + +Common values: +| Version | URL | +|---------|-----| +| Draft-07 (recommended for VS Code) | `https://json-schema.org/draft-07/schema#` | +| Draft 2020-12 (default) | `https://json-schema.org/draft/2020-12/schema` | + ## Star History diff --git a/go.mod b/go.mod index c48f7a6..6a5fcb8 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.24 require ( github.com/gotd/td v0.121.0 + github.com/invopop/jsonschema v0.12.0 github.com/metoro-io/mcp-golang v0.8.0 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.34.0 @@ -28,7 +29,6 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/gotd/ige v0.2.2 // indirect github.com/gotd/neo v0.1.5 // indirect - github.com/invopop/jsonschema v0.12.0 // indirect github.com/klauspost/compress v1.18.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.14 // indirect diff --git a/main.go b/main.go index 64b7442..40db924 100644 --- a/main.go +++ b/main.go @@ -59,6 +59,11 @@ func main() { Value: sesionPath, Sources: cli.EnvVars("TG_SESSION_PATH"), }, + &cli.StringFlag{ + Name: "schema-version", + Usage: "JSON Schema version URL (e.g. https://json-schema.org/draft-07/schema#)", + Sources: cli.EnvVars("TG_SCHEMA_VERSION"), + }, &cli.BoolFlag{ Name: "dry", Usage: "Test configuration", diff --git a/serve.go b/serve.go index f69d239..7315655 100644 --- a/serve.go +++ b/serve.go @@ -7,6 +7,7 @@ import ( "os" "github.com/chaindead/telegram-mcp/internal/tg" + "github.com/invopop/jsonschema" mcp "github.com/metoro-io/mcp-golang" "github.com/metoro-io/mcp-golang/transport/stdio" @@ -20,6 +21,10 @@ func serve(ctx context.Context, cmd *cli.Command) error { sessionPath := cmd.String("session") dryRun := cmd.Bool("dry") + if schemaURL := cmd.String("schema-version"); schemaURL != "" { + jsonschema.Version = schemaURL + } + _, err := os.Stat(sessionPath) if err != nil { return fmt.Errorf("session file not found(%s): %w", sessionPath, err)