Skip to content

Commit 1c2c03a

Browse files
authored
Merge pull request #16 from chaindead/fix/json-schema-version
fix: make JSON Schema version configurable to support VS Code and other clients
2 parents ba91980 + 7648836 commit 1c2c03a

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The server is a bridge between the Telegram API and the AI assistants and is bas
3030
- [Configuration](#configuration)
3131
- [Authorization](#authorization)
3232
- [Client Configuration](#client-configuration)
33+
- [JSON Schema Version](#json-schema-version)
3334
- [Star History](#star-history)
3435

3536
## What is MCP?
@@ -263,6 +264,16 @@ Example of Configuring Claude Desktop to recognize the Telegram MCP server.
263264
}
264265
```
265266

267+
### JSON Schema Version
268+
269+
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.
270+
271+
Common values:
272+
| Version | URL |
273+
|---------|-----|
274+
| Draft-07 (recommended for VS Code) | `https://json-schema.org/draft-07/schema#` |
275+
| Draft 2020-12 (default) | `https://json-schema.org/draft/2020-12/schema` |
276+
266277
## Star History
267278

268279
<a href="https://www.star-history.com/#chaindead/telegram-mcp&Date">

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24
44

55
require (
66
github.com/gotd/td v0.121.0
7+
github.com/invopop/jsonschema v0.12.0
78
github.com/metoro-io/mcp-golang v0.8.0
89
github.com/pkg/errors v0.9.1
910
github.com/rs/zerolog v1.34.0
@@ -28,7 +29,6 @@ require (
2829
github.com/google/uuid v1.6.0 // indirect
2930
github.com/gotd/ige v0.2.2 // indirect
3031
github.com/gotd/neo v0.1.5 // indirect
31-
github.com/invopop/jsonschema v0.12.0 // indirect
3232
github.com/klauspost/compress v1.18.0 // indirect
3333
github.com/mailru/easyjson v0.7.7 // indirect
3434
github.com/mattn/go-colorable v0.1.14 // indirect

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ func main() {
5959
Value: sesionPath,
6060
Sources: cli.EnvVars("TG_SESSION_PATH"),
6161
},
62+
&cli.StringFlag{
63+
Name: "schema-version",
64+
Usage: "JSON Schema version URL (e.g. https://json-schema.org/draft-07/schema#)",
65+
Sources: cli.EnvVars("TG_SCHEMA_VERSION"),
66+
},
6267
&cli.BoolFlag{
6368
Name: "dry",
6469
Usage: "Test configuration",

serve.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88

99
"github.com/chaindead/telegram-mcp/internal/tg"
10+
"github.com/invopop/jsonschema"
1011

1112
mcp "github.com/metoro-io/mcp-golang"
1213
"github.com/metoro-io/mcp-golang/transport/stdio"
@@ -20,6 +21,10 @@ func serve(ctx context.Context, cmd *cli.Command) error {
2021
sessionPath := cmd.String("session")
2122
dryRun := cmd.Bool("dry")
2223

24+
if schemaURL := cmd.String("schema-version"); schemaURL != "" {
25+
jsonschema.Version = schemaURL
26+
}
27+
2328
_, err := os.Stat(sessionPath)
2429
if err != nil {
2530
return fmt.Errorf("session file not found(%s): %w", sessionPath, err)

0 commit comments

Comments
 (0)