Skip to content

Commit b8bb125

Browse files
authored
Merge pull request #2306 from onflow/peter/mcp-server
Add flow mcp command for Cadence MCP server
2 parents e3fcccf + 5cb8d59 commit b8bb125

10 files changed

Lines changed: 1206 additions & 13 deletions

File tree

cmd/flow/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/onflow/flow-cli/internal/events"
3636
evm "github.com/onflow/flow-cli/internal/evm"
3737
"github.com/onflow/flow-cli/internal/keys"
38+
"github.com/onflow/flow-cli/internal/mcp"
3839
"github.com/onflow/flow-cli/internal/project"
3940
"github.com/onflow/flow-cli/internal/quick"
4041
"github.com/onflow/flow-cli/internal/schedule"
@@ -92,6 +93,7 @@ func main() {
9293
cmd.AddCommand(dependencymanager.Cmd)
9394
cmd.AddCommand(evm.Cmd)
9495
cmd.AddCommand(schedule.Cmd)
96+
cmd.AddCommand(mcp.Cmd)
9597

9698
command.InitFlags(cmd)
9799
cmd.AddGroup(&cobra.Group{

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/getsentry/sentry-go v0.43.0
1313
github.com/gosuri/uilive v0.0.4
1414
github.com/logrusorgru/aurora/v4 v4.0.0
15+
github.com/mark3labs/mcp-go v0.45.0
1516
github.com/onflow/cadence v1.10.0
1617
github.com/onflow/cadence-tools/languageserver v1.10.0
1718
github.com/onflow/cadence-tools/lint v1.9.0
@@ -60,11 +61,13 @@ require (
6061
github.com/VictoriaMetrics/fastcache v1.13.0 // indirect
6162
github.com/atotto/clipboard v0.1.4 // indirect
6263
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
64+
github.com/bahlo/generic-list-go v0.2.0 // indirect
6365
github.com/benbjohnson/clock v1.3.5 // indirect
6466
github.com/beorn7/perks v1.0.1 // indirect
6567
github.com/bits-and-blooms/bitset v1.24.4 // indirect
6668
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
6769
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect
70+
github.com/buger/jsonparser v1.1.2 // indirect
6871
github.com/c-bata/go-prompt v0.2.6 // indirect
6972
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
7073
github.com/cespare/xxhash v1.1.0 // indirect
@@ -149,10 +152,9 @@ require (
149152
github.com/huandu/go-clone v1.6.0 // indirect
150153
github.com/huandu/go-clone/generic v1.7.2 // indirect
151154
github.com/huin/goupnp v1.3.0 // indirect
152-
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
153155
github.com/improbable-eng/grpc-web v0.15.0 // indirect
154156
github.com/inconshreveable/mousetrap v1.1.0 // indirect
155-
github.com/invopop/jsonschema v0.7.0 // indirect
157+
github.com/invopop/jsonschema v0.13.0 // indirect
156158
github.com/ipfs/bbloom v0.0.4 // indirect
157159
github.com/ipfs/boxo v0.17.1-0.20240131173518-89bceff34bf1 // indirect
158160
github.com/ipfs/go-block-format v0.2.0 // indirect
@@ -179,6 +181,7 @@ require (
179181
github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 // indirect
180182
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
181183
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
184+
github.com/mailru/easyjson v0.7.7 // indirect
182185
github.com/mattn/go-colorable v0.1.14 // indirect
183186
github.com/mattn/go-isatty v0.0.20 // indirect
184187
github.com/mattn/go-localereader v0.0.1 // indirect
@@ -263,9 +266,11 @@ require (
263266
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
264267
github.com/vmihailenco/msgpack/v4 v4.3.11 // indirect
265268
github.com/vmihailenco/tagparser v0.1.1 // indirect
269+
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
266270
github.com/wlynxg/anet v0.0.5 // indirect
267271
github.com/x448/float16 v0.8.4 // indirect
268272
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
273+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
269274
github.com/zeebo/blake3 v0.2.4 // indirect
270275
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
271276
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect

go.sum

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
9292
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
9393
github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
9494
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
95+
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
96+
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
9597
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
9698
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
9799
github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
@@ -106,6 +108,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurT
106108
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
107109
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 h1:SDlJ7bAm4ewvrmZtR0DaiYbQGdKPeaaIm7bM+qRhFeU=
108110
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
111+
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
112+
github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
109113
github.com/bytedance/sonic v1.11.5 h1:G00FYjjqll5iQ1PYXynbg/hyzqBqavH8Mo9/oTopd9k=
110114
github.com/bytedance/sonic v1.11.5/go.mod h1:X2PC2giUdj/Cv2lliWFLk6c/DUQok5rViJSemeB0wDw=
111115
github.com/bytedance/sonic/loader v0.1.0 h1:skjHJ2Bi9ibbq3Dwzh1w42MQ7wZJrXmEZr/uqUn3f0Q=
@@ -529,17 +533,15 @@ github.com/huandu/go-clone/generic v1.7.2/go.mod h1:xgd9ZebcMsBWWcBx5mVMCoqMX24g
529533
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
530534
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
531535
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
532-
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk=
533-
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
534536
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
535537
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
536538
github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8=
537539
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
538540
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
539541
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
540542
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
541-
github.com/invopop/jsonschema v0.7.0 h1:2vgQcBz1n256N+FpX3Jq7Y17AjYt46Ig3zIWyy770So=
542-
github.com/invopop/jsonschema v0.7.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0=
543+
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
544+
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
543545
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
544546
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
545547
github.com/ipfs/boxo v0.17.1-0.20240131173518-89bceff34bf1 h1:5H/HYvdmbxp09+sAvdqJzyrWoyCS6OroeW9Ym06Tb+0=
@@ -574,6 +576,7 @@ github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
574576
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
575577
github.com/jordanschalm/lockctx v0.1.0 h1:2ZziSl5zejl5VSRUjl+UtYV94QPFQgO9bekqWPOKUQw=
576578
github.com/jordanschalm/lockctx v0.1.0/go.mod h1:qsnXMryYP9X7JbzskIn0+N40sE6XNXLr9kYRRP6rwXU=
579+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
577580
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
578581
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
579582
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@@ -659,6 +662,10 @@ github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQ
659662
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
660663
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
661664
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
665+
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
666+
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
667+
github.com/mark3labs/mcp-go v0.45.0 h1:s0S8qR/9fWaQ3pHxz7pm1uQ0DrswoSnRIxKIjbiQtkc=
668+
github.com/mark3labs/mcp-go v0.45.0/go.mod h1:YnJfOL382MIWDx1kMY+2zsRHU/q78dBg9aFb8W6Thdw=
662669
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk=
663670
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU=
664671
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -1075,7 +1082,6 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
10751082
github.com/stretchr/testify v0.0.0-20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
10761083
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
10771084
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1078-
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
10791085
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
10801086
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
10811087
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -1122,6 +1128,8 @@ github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0
11221128
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
11231129
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
11241130
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
1131+
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
1132+
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
11251133
github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
11261134
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
11271135
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
@@ -1131,6 +1139,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
11311139
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
11321140
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
11331141
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
1142+
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
1143+
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
11341144
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
11351145
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
11361146
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=

internal/cadence/linter.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ func newLinter(state *flowkit.State) *linter {
7878

7979
func (l *linter) lintFile(
8080
filePath string,
81+
) (diagnostics []analysis.Diagnostic, err error) {
82+
code, readErr := l.state.ReadFile(filePath)
83+
if readErr != nil {
84+
return nil, readErr
85+
}
86+
87+
return l.lintCode(code, common.StringLocation(filePath))
88+
}
89+
90+
func (l *linter) lintCode(
91+
code []byte,
92+
location common.Location,
8193
) (diagnostics []analysis.Diagnostic, err error) {
8294
// Recover from panics in the Cadence checker
8395
defer func() {
@@ -88,12 +100,6 @@ func (l *linter) lintFile(
88100
}()
89101

90102
diagnostics = make([]analysis.Diagnostic, 0)
91-
location := common.StringLocation(filePath)
92-
93-
code, readErr := l.state.ReadFile(filePath)
94-
if readErr != nil {
95-
return nil, readErr
96-
}
97103
codeStr := string(code)
98104

99105
// Parse program & convert any parsing errors to diagnostics
@@ -181,6 +187,13 @@ func (l *linter) lintFile(
181187
return diagnostics, nil
182188
}
183189

190+
// LintCode runs all registered Cadence lint analyzers on inline code.
191+
// This is the public entry point used by the MCP server.
192+
func LintCode(code string, state *flowkit.State) ([]analysis.Diagnostic, error) {
193+
l := newLinter(state)
194+
return l.lintCode([]byte(code), common.StringLocation("code.cdc"))
195+
}
196+
184197
// isContractName returns true if the location string is a contract name (not a file path)
185198
func isContractName(locationString string) bool {
186199
return !strings.HasSuffix(locationString, ".cdc")

internal/mcp/integration_test.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Flow CLI
3+
*
4+
* Copyright Flow Foundation
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package mcp
20+
21+
import (
22+
"context"
23+
"os"
24+
"testing"
25+
26+
mcplib "github.com/mark3labs/mcp-go/mcp"
27+
"github.com/stretchr/testify/assert"
28+
"github.com/stretchr/testify/require"
29+
)
30+
31+
func skipIfNoNetwork(t *testing.T) {
32+
t.Helper()
33+
if os.Getenv("SKIP_NETWORK_TESTS") != "" {
34+
t.Skip("Skipping network test (SKIP_NETWORK_TESTS is set)")
35+
}
36+
}
37+
38+
func TestIntegration_GetContractSource(t *testing.T) {
39+
t.Parallel()
40+
skipIfNoNetwork(t)
41+
42+
mctx := &mcpContext{state: nil}
43+
req := mcplib.CallToolRequest{}
44+
req.Params.Arguments = map[string]any{
45+
"address": "0x1654653399040a61",
46+
"network": "mainnet",
47+
}
48+
49+
result, err := mctx.getContractSource(context.Background(), req)
50+
require.NoError(t, err)
51+
assert.False(t, result.IsError)
52+
text := result.Content[0].(mcplib.TextContent).Text
53+
assert.Contains(t, text, "FlowToken")
54+
}
55+
56+
func TestIntegration_GetContractCode(t *testing.T) {
57+
t.Parallel()
58+
skipIfNoNetwork(t)
59+
60+
mctx := &mcpContext{state: nil}
61+
req := mcplib.CallToolRequest{}
62+
req.Params.Arguments = map[string]any{
63+
"address": "0x1654653399040a61",
64+
"contract_name": "FlowToken",
65+
"network": "mainnet",
66+
}
67+
68+
result, err := mctx.getContractCode(context.Background(), req)
69+
require.NoError(t, err)
70+
assert.False(t, result.IsError)
71+
text := result.Content[0].(mcplib.TextContent).Text
72+
assert.Contains(t, text, "FlowToken")
73+
}
74+
75+
func TestIntegration_ExecuteScript(t *testing.T) {
76+
t.Parallel()
77+
skipIfNoNetwork(t)
78+
79+
mctx := &mcpContext{state: nil}
80+
req := mcplib.CallToolRequest{}
81+
req.Params.Arguments = map[string]any{
82+
"code": `access(all) fun main(): Int { return 42 }`,
83+
"network": "mainnet",
84+
}
85+
86+
result, err := mctx.cadenceExecuteScript(context.Background(), req)
87+
require.NoError(t, err)
88+
assert.False(t, result.IsError)
89+
text := result.Content[0].(mcplib.TextContent).Text
90+
assert.Contains(t, text, "42")
91+
}

0 commit comments

Comments
 (0)