Skip to content

Add MCP server sub-command using mcp-go library#6

Merged
alexec merged 9 commits intomainfrom
copilot/add-mcp-server-sub-command
Oct 30, 2025
Merged

Add MCP server sub-command using mcp-go library#6
alexec merged 9 commits intomainfrom
copilot/add-mcp-server-sub-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 30, 2025

  • Understand current codebase structure and build/test process
  • Establish baseline (build and test passes)
  • Refactor to use github.com/mark3labs/mcp-go library
  • Simplified implementation from 263 lines to 67 lines (74% reduction)
  • Updated tests to match new implementation
  • All tests passing
  • Manual verification successful
  • Updated README with MCP server configuration example
  • Removed client interaction JSON from README
  • Updated MCP config to use slack configure (keyring) instead of hardcoded token
  • Added example usage for both CLI and MCP server modes
  • Code review and security scan
Original prompt

Add a new sub-command that start the tool up as an MCP server.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits October 30, 2025 22:19
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new sub-command to start tool as MCP server Add MCP server sub-command for JSON-RPC tool integration Oct 30, 2025
Copilot AI requested a review from alexec October 30, 2025 22:28
mcp.go Outdated
)

// MCP JSON-RPC 2.0 structures
type JSONRPCRequest struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot would it be easier to use an MCP library? What options are there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I researched available Go MCP libraries. Here are the main options:

Available Libraries:

  1. github.com/mark3labs/mcp-go - Community MCP SDK for Go (most mature option)
  2. github.com/metoro-io/mcp-golang - Another community implementation
  3. Official SDK - Anthropic has official SDKs for TypeScript/Python but not Go yet

Current Implementation (263 lines):

  • ✅ Zero external dependencies (aligns with project goal: "without the need to install a runtime")
  • ✅ ~90 lines of struct definitions, ~170 lines of logic
  • ✅ Already working and tested
  • ✅ Complete control over protocol details

Using a Library:

  • Would add external dependency (goes against project philosophy)
  • Libraries are community-maintained, not official
  • Current implementation is straightforward JSON-RPC - not complex enough to justify dependency
  • Would still need similar tool registration/handler code

Recommendation: Keep current implementation. The JSON-RPC handling is simple, and adding a dependency would contradict the project's "zero runtime dependencies" goal. The 263 lines are well-structured and easy to maintain.

Would you like me to switch to using a library instead? If so, which one would you prefer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please use github.com/mark3labs/mcp-go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Refactored to use github.com/mark3labs/mcp-go library in commit 1a75235.

Changes:

  • Reduced mcp.go from 263 lines to 67 lines (74% reduction)
  • Simplified tests from 169 lines to 52 lines
  • All functionality maintained and verified

The library handles all JSON-RPC protocol details, MCP structures, and stdio transport, making the code much cleaner and easier to maintain.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 30, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • slack.com
    • Triggering command: ./slack mcp-server (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add MCP server sub-command for JSON-RPC tool integration Add MCP server sub-command using mcp-go library Oct 30, 2025
@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 30, 2025

https://gh.io/copilot-coding-agent-docs please use github.com/mark3labs/mcp-go

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 30, 2025

@copilot Add an example of MCP server JSON you need to configure, remove the "client interaction".

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot Add an example of MCP server JSON you need to configure, remove the "client interaction".

Updated in commit a838a30. Added MCP server configuration example and removed the client interaction JSON. The README now shows how to configure the server in an MCP client configuration file.

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 30, 2025

@copilot Users should run slack configure prior to using the tool, rather than hard-code the JIRA_TOKEN into the JSON.

…token

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot Users should run slack configure prior to using the tool, rather than hard-code the JIRA_TOKEN into the JSON.

Updated in commit c3d580e. The MCP configuration now:

  1. Instructs users to run slack configure first (stores token in keyring)
  2. Removed the hardcoded SLACK_TOKEN from the JSON configuration
  3. The MCP server will automatically use the token from the keyring

@alexec
Copy link
Copy Markdown
Contributor

alexec commented Oct 30, 2025

@copilot please add an example message to send, e.g. "Slack alex_collins@intuit.com to say how much you like this tool."

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot please add an example message to send, e.g. "Slack alex_collins@intuit.com to say how much you like this tool."

Added in commit 3b67ada. The README now includes:

  1. A CLI example: slack send-message alex_collins@intuit.com "I love this tool! It makes Slack integration so easy."
  2. An MCP server example usage: "Slack alex_collins@intuit.com to say how much you like this tool."

@alexec alexec marked this pull request as ready for review October 30, 2025 23:33
@alexec alexec merged commit 80ea54c into main Oct 30, 2025
2 checks passed
@alexec alexec deleted the copilot/add-mcp-server-sub-command branch October 30, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants