Skip to content

Add Sei MCP Server as new package#249

Merged
codebycarson merged 19 commits into
mainfrom
feature/mcp-server
May 29, 2025
Merged

Add Sei MCP Server as new package#249
codebycarson merged 19 commits into
mainfrom
feature/mcp-server

Conversation

@codebycarson

@codebycarson codebycarson commented May 23, 2025

Copy link
Copy Markdown
Collaborator

Sei MCP Server

This PR adds a new package called @sei-js/mcp-server for use with LLM's. It is a fork of a more generalized EVM MCP and will be improved moving forwards. See the README for local development. This package uses the same build tools and release workflows as every other @sei-js package.

This MCP server contains a variety of prompts and tools included and works in stdio or http mode.

Adding to Claude

Claude > Settings > Developer > Edit Settings

{
  "mcpServers": {
    "sei": {
      "command": "npx",
      "args": [
        "-y",
        "@sei-js/mcp-server"
      ],
      "env": {
        "PRIVATE_KEY": "0xYOUR_PRIVATE_KEY"
      }
    }
  }
}

@changeset-bot

changeset-bot Bot commented May 23, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 467bb3b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sei-js/mcp-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codebycarson codebycarson requested a review from Copilot May 23, 2025 23:38

Copilot AI left a comment

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.

Pull Request Overview

Adds a new @sei-js/mcp-server package to provide an MCP server for Sei/EVM networks, including a stdio entrypoint, core blockchain service utilities, and a suite of LLM prompts.

  • Introduces src/index.ts to launch the server over stdio
  • Implements core services (clients, transactions, tokens, contracts, blocks, balance, utils)
  • Registers a variety of EVM-related prompts and configures environment/chain mappings

Reviewed Changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/mcp-server/src/index.ts Server startup entrypoint using StdioServerTransport
packages/mcp-server/src/core/services/utils.ts Utility functions for parsing, formatting, and address validation
packages/mcp-server/src/core/services/clients.ts Public and wallet client creation with caching
packages/mcp-server/src/core/services/transactions.ts Transaction retrieval and gas estimation
packages/mcp-server/src/core/services/tokens.ts ERC20, ERC721, ERC1155 token data readers
packages/mcp-server/src/core/services/contracts.ts Contract read/write, logs, and contract detection
packages/mcp-server/src/core/services/blocks.ts Block retrieval utilities
packages/mcp-server/src/core/services/balance.ts Balance queries and NFT ownership checks
packages/mcp-server/src/core/services/index.ts Aggregates and re-exports all services and common types
packages/mcp-server/src/core/prompts.ts Registration of EVM-related LLM prompts
packages/mcp-server/src/core/config.ts Environment variable loading and key formatting
packages/mcp-server/src/core/chains.ts Chain ID and RPC URL resolution mappings
packages/mcp-server/package.json Package metadata, dependencies, scripts, and publish config
packages/mcp-server/jest.config.js Jest setup
packages/mcp-server/LICENSE MIT License
packages/mcp-server/.npmignore Files to exclude from npm package
packages/mcp-server/.gitignore Files to ignore in git
packages/mcp-server/.env.example Example environment variables
.changeset/thirty-results-thank.md Initial release changeset
Comments suppressed due to low confidence (4)

packages/mcp-server/src/index.ts:10

  • The startup message refers to "EVM MCP Server" but this package is called sei-js/mcp-server. Consider updating the log to "Sei MCP Server running on stdio" for consistency.
console.error("EVM MCP Server running on stdio");

packages/mcp-server/src/core/services/balance.ts:182

  • The as Promise<bigint> assertion is incorrect: the await unwraps the promise, so you should assert the result as bigint (or remove the assertion entirely).
return await readContract({ address: validatedTokenAddress, abi: erc721Abi, functionName: 'balanceOf', args: [validatedOwnerAddress] }, network) as Promise<bigint>;

packages/mcp-server/src/core/services/utils.ts:14

  • The formatJson and validateAddress utilities are untested. Consider adding unit tests to cover big-int JSON formatting and address validation logic.
formatJson: (obj: unknown): string => JSON.stringify(obj, (_, value) =>

packages/mcp-server/package.json:6

  • The bin field points to ./bin/cli.js, but no such file exists in the package. Add the CLI script or remove/update the bin entry to prevent publish errors.
"bin": "./bin/cli.js",

@dssei dssei left a comment

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.

lgtm, We need to update the readme with correct repo and mcp configs

Comment thread packages/mcp-server/README.md Outdated

## 🛠️ Prerequisites

- [Bun](https://bun.sh/) 1.0.0 or higher

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.

We probably do not need that anymore?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated this

Comment thread packages/mcp-server/README.md Outdated

```bash
# Clone the repository
git clone https://github.com/sei-protocol/sei-mcp-server.git

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.

moved to sei-js

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated this

Comment thread packages/mcp-server/README.md Outdated
"command": "npx",
"args": [
"-y",
"@sei-protocol/sei-mcp-server"

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.

needs update

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

/**
* Read from a contract for a specific network
*/
export async function readContract(params: ReadContractParameters, network = 'sei') {

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pulled them all in now and updated the tests

@codecov-commenter

codecov-commenter commented May 24, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 7.18%. Comparing base (aeeee09) to head (467bb3b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #249      +/-   ##
========================================
+ Coverage   6.18%   7.18%   +0.99%     
========================================
  Files        271     284      +13     
  Lines      48957   49484     +527     
  Branches   17117   17235     +118     
========================================
+ Hits        3030    3557     +527     
  Misses     45927   45927              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codebycarson codebycarson requested a review from Copilot May 24, 2025 01:20

Copilot AI left a comment

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.

Pull Request Overview

This PR introduces a new package, @sei-js/mcp-server, which provides an MCP server designed for interacting with EVM-compatible networks via both stdio and HTTP modes. Key changes include the initialization of a Stdio server transport, the implementation of various blockchain service functions (such as transaction, balance, token, contract, and block handling), and the registration of multiple prompts using zod validation.

Reviewed Changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/mcp-server/src/index.ts Initializes the MCP server and connects it to a Stdio transport.
packages/mcp-server/src/core/services/*.ts Implements various blockchain service functions and helper utils.
packages/mcp-server/src/core/prompts.ts Registers multiple EVM-related prompts using zod for input schema.
packages/mcp-server/src/core/config.ts, chains.ts Sets up environment variables, network mappings, and RPC URLs.
Other files (package.json, jest.config.js, etc.) Provide package metadata, build configuration, and supporting files.

* @returns Transaction hash
* @throws Error if no private key is available
*/
export async function writeContract(params: Record<string, any>, network = DEFAULT_NETWORK): Promise<Hash> {

Copilot AI May 24, 2025

Copy link

Choose a reason for hiding this comment

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

Consider defining a specific type for the 'params' parameter in writeContract instead of using Record<string, any> to enhance type safety and clarity.

Suggested change
export async function writeContract(params: Record<string, any>, network = DEFAULT_NETWORK): Promise<Hash> {
export async function writeContract(params: WriteContractParameters, network = DEFAULT_NETWORK): Promise<Hash> {

Copilot uses AI. Check for mistakes.
codebycarson and others added 8 commits May 23, 2025 18:33
- Fixed formatting issues according to Biome
- Fixed Typescript warnings line non-null assertions
- Added test cases for everything
- Fixed windsurf MCP issues
- Removed CT changeset as it is delayed
@codebycarson codebycarson merged commit 4e2719c into main May 29, 2025
3 checks passed
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.

4 participants