bug: fix json schema

This commit is contained in:
chaindead 2026-02-28 00:18:58 +03:00
parent ba919808e0
commit 764883677e
4 changed files with 22 additions and 1 deletions

View file

@ -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
<a href="https://www.star-history.com/#chaindead/telegram-mcp&Date">

2
go.mod
View file

@ -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

View file

@ -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",

View file

@ -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)