Skip to content

Commit 5a007d2

Browse files
committed
feat(schema): add example creating an mcp.Tool from a value in schema
1 parent 64d343f commit 5a007d2

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
![https://github.com/RichardLitt/standard-readme](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)
77
![GitHub License](https://img.shields.io/github/license/selesy/ethereum-mcp)
88
![GitHub Release](https://img.shields.io/github/v/release/selesy/ethereum-mcp)
9+
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
910

1011
The `ethereum-mcp` library provides Go packages to make creating Model Context Protocol servers for Ethereum block-chains easier.
1112

@@ -21,7 +22,7 @@ go get github.com/selesy/ethereum-mcp
2122

2223
The `/pkg/scheam` package provides "augmented" JSONSchema files and their associated Go embeddings in a format that's suitable for use as a "Raw Schema" with the `mcp-go` library's [`NewToolWithRawSchema`](https://pkg.go.dev/github.com/mark3labs/mcp-go/mcp#NewToolWithRawSchema) constructor.
2324

24-
Full documentation for this library is available as [Go docs](https://pkg.go.dev/github.com/selesy/ethereum-mcp).
25+
Full documentation for this library including examples is available as [Go docs](https://pkg.go.dev/github.com/selesy/ethereum-mcp).
2526

2627
## Contributing
2728

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ tool (
99

1010
require (
1111
github.com/invopop/yaml v0.3.1
12+
github.com/mark3labs/mcp-go v0.39.0
1213
github.com/selesy/jsonschema v0.14.0-rc1
1314
github.com/stretchr/testify v1.11.0
1415
gotest.tools/v3 v3.5.2
@@ -22,11 +23,14 @@ require (
2223
github.com/google/go-cmp v0.7.0 // indirect
2324
github.com/google/go-github/v74 v74.0.0 // indirect
2425
github.com/google/go-querystring v1.1.0 // indirect
26+
github.com/invopop/jsonschema v0.13.0 // indirect
2527
github.com/lmittmann/tint v1.1.2 // indirect
2628
github.com/mailru/easyjson v0.7.7 // indirect
2729
github.com/pmezard/go-difflib v1.0.0 // indirect
2830
github.com/selesy/ethereum-mcp/gen v0.0.0-20250901154801-d4c233633a9f // indirect
31+
github.com/spf13/cast v1.7.1 // indirect
2932
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
33+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
3034
golang.org/x/mod v0.22.0 // indirect
3135
golang.org/x/sync v0.10.0 // indirect
3236
golang.org/x/sys v0.29.0 // indirect

go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo=
66
github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc=
77
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
10+
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
911
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786 h1:rcv+Ippz6RAtvaGgKxc+8FQIpxHgsF+HBzPyYL2cyVU=
1012
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o=
1113
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
@@ -17,23 +19,37 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
1719
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
1820
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
1921
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
22+
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
23+
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
2024
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
2125
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
2226
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
27+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
28+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
29+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
30+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2331
github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w=
2432
github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
2533
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
2634
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
35+
github.com/mark3labs/mcp-go v0.39.0 h1:dQwaOADzUJ1ROslEJB8QV+4u/8XQCqH9ylB//x8cCEQ=
36+
github.com/mark3labs/mcp-go v0.39.0/go.mod h1:T7tUa2jO6MavG+3P25Oy/jR7iCeJPHImCZHRymCn39g=
2737
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2838
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
39+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
40+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
2941
github.com/selesy/ethereum-mcp/gen v0.0.0-20250901154801-d4c233633a9f h1:P2q1cgIP7V0nt495obAAh7rI5te82hu9KyZrQnwJ4I4=
3042
github.com/selesy/ethereum-mcp/gen v0.0.0-20250901154801-d4c233633a9f/go.mod h1:spQUq+TrIVOj+XfbHVOZwB+T9WYcJ3+mAdM0vsUDe8E=
3143
github.com/selesy/jsonschema v0.14.0-rc1 h1:rGdpQeWFk76uxpmOx0lrA9Lwb+eVTBPZ6io5IC7rVIk=
3244
github.com/selesy/jsonschema v0.14.0-rc1/go.mod h1:QgbdOu2y8GVkNvmK+npB2dvXlbdEL0eQ2LrRcHRTcKU=
45+
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
46+
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
3347
github.com/stretchr/testify v1.11.0 h1:ib4sjIrwZKxE5u/Japgo/7SJV3PvgjGiRNAvTVGqQl8=
3448
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
3549
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
3650
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
51+
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
52+
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
3753
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
3854
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
3955
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=

pkg/schema/schema_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package schema_test
2+
3+
import (
4+
"github.com/mark3labs/mcp-go/mcp"
5+
6+
"github.com/selesy/ethereum-mcp/pkg/schema"
7+
)
8+
9+
func ExampleEthGetBlockByNumberSchema() { //nolint:govet
10+
tool := mcp.NewToolWithRawSchema(
11+
"eth_getBlockByNumber",
12+
"Returns information about a block by number.",
13+
schema.EthGetBlockByNumberSchema,
14+
)
15+
16+
// Do something with the created mcp.Tool.
17+
_ = tool
18+
}

0 commit comments

Comments
 (0)