-
Notifications
You must be signed in to change notification settings - Fork 82
Add flow mcp command for Cadence MCP server #2306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
12a7036
Add design spec for flow mcp command
peterargue 1ba847c
Soften code review language in MCP design spec
peterargue 69257af
Clarify LSP document lifecycle in MCP design spec
peterargue 3477f02
Add implementation plan for flow mcp command
peterargue 02c5723
Add flow mcp command scaffold with mcp-go dependency
peterargue 67b6f24
Add LSP wrapper for in-process Cadence language server
peterargue 773a2bf
Add tool handler implementations and wire into MCP server
peterargue 75fac3e
Add tool handler tests
peterargue 14bf6b0
Add integration tests for network tools
peterargue 24683bb
Fix integration test expectations for FlowToken address
peterargue f6743fd
Add code review rules for cadence_code_review tool
peterargue 8d28827
Upgrade buger/jsonparser to v1.1.2 to fix CVE
peterargue 4d204ae
Remove planning docs from PR
peterargue 4cdf25c
Add file parameter as alternative to code for all Cadence tools
peterargue dd3688b
Add t.Parallel() to all tests
peterargue 501221e
Replace diagnostic append with replace, filter by scratch URI
peterargue c1cd223
Warn on invalid flow.json instead of silently falling back
peterargue 9a69034
Validate Flow address to prevent silent empty address queries
peterargue 3aeaab3
Use FindAllStringSubmatch to catch multiple matches per line
peterargue b5e2b7a
Use secure gRPC gateway when network has a configured key
peterargue b4eadb7
Remove unused network param from LSP wrapper and tool schemas
peterargue 0609dd3
Remove file parameter from tools to prevent sandbox bypass
peterargue 1281ee7
Fix goimports formatting
peterargue 73c2ffc
Use generated String() methods from cadence-tools for SymbolKind and …
peterargue f78a42d
Add cadence_lint tool using AST-based cadence-tools analyzers
peterargue 7520cab
Fix goimports formatting
peterargue dcbb4b5
Reuse existing cadence linter via exported LintCode instead of reimpl…
peterargue 7c5b618
Remove cadence_lint MCP tool — available via flow cadence lint CLI
peterargue b489ac8
Fix goimports formatting
peterargue ffe581d
Merge branch 'master' into peter/mcp-server
turbolent 5cb8d59
remove code review / audit
turbolent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * Flow CLI | ||
| * | ||
| * Copyright Flow Foundation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package mcp | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
| "testing" | ||
|
|
||
| mcplib "github.com/mark3labs/mcp-go/mcp" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func skipIfNoNetwork(t *testing.T) { | ||
| t.Helper() | ||
| if os.Getenv("SKIP_NETWORK_TESTS") != "" { | ||
| t.Skip("Skipping network test (SKIP_NETWORK_TESTS is set)") | ||
| } | ||
| } | ||
|
|
||
| func TestIntegration_GetContractSource(t *testing.T) { | ||
| t.Parallel() | ||
| skipIfNoNetwork(t) | ||
|
|
||
| mctx := &mcpContext{state: nil} | ||
| req := mcplib.CallToolRequest{} | ||
| req.Params.Arguments = map[string]any{ | ||
| "address": "0x1654653399040a61", | ||
| "network": "mainnet", | ||
| } | ||
|
|
||
| result, err := mctx.getContractSource(context.Background(), req) | ||
| require.NoError(t, err) | ||
| assert.False(t, result.IsError) | ||
| text := result.Content[0].(mcplib.TextContent).Text | ||
| assert.Contains(t, text, "FlowToken") | ||
| } | ||
|
|
||
| func TestIntegration_GetContractCode(t *testing.T) { | ||
| t.Parallel() | ||
| skipIfNoNetwork(t) | ||
|
|
||
| mctx := &mcpContext{state: nil} | ||
| req := mcplib.CallToolRequest{} | ||
| req.Params.Arguments = map[string]any{ | ||
| "address": "0x1654653399040a61", | ||
| "contract_name": "FlowToken", | ||
| "network": "mainnet", | ||
| } | ||
|
|
||
| result, err := mctx.getContractCode(context.Background(), req) | ||
| require.NoError(t, err) | ||
| assert.False(t, result.IsError) | ||
| text := result.Content[0].(mcplib.TextContent).Text | ||
| assert.Contains(t, text, "FlowToken") | ||
| } | ||
|
|
||
| func TestIntegration_ExecuteScript(t *testing.T) { | ||
| t.Parallel() | ||
| skipIfNoNetwork(t) | ||
|
|
||
| mctx := &mcpContext{state: nil} | ||
| req := mcplib.CallToolRequest{} | ||
| req.Params.Arguments = map[string]any{ | ||
| "code": `access(all) fun main(): Int { return 42 }`, | ||
| "network": "mainnet", | ||
| } | ||
|
|
||
| result, err := mctx.cadenceExecuteScript(context.Background(), req) | ||
| require.NoError(t, err) | ||
| assert.False(t, result.IsError) | ||
| text := result.Content[0].(mcplib.TextContent).Text | ||
| assert.Contains(t, text, "42") | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.