Skip to content

Commit 36db810

Browse files
committed
feat: align with MCP 2026-07-28
1 parent 128ac3d commit 36db810

14 files changed

Lines changed: 598 additions & 483 deletions

README.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)
44
![EVM Networks](https://img.shields.io/badge/Networks-60+-green)
55
![TypeScript](https://img.shields.io/badge/TypeScript-5.8+-3178C6)
6-
![MCP](https://img.shields.io/badge/MCP-1.22.0+-blue)
6+
![MCP](https://img.shields.io/badge/MCP-2026--07--28-blue)
77
![Viem](https://img.shields.io/badge/Viem-2.39.3+-green)
88

9-
A comprehensive Model Context Protocol (MCP) server that provides blockchain services across 60+ EVM-compatible networks. This server enables AI agents to interact with Ethereum, Optimism, Arbitrum, Base, Polygon, and many other EVM chains with a unified interface through 22 tools and 10 AI-guided prompts.
9+
A comprehensive Model Context Protocol (MCP) server that provides blockchain services across 60+ EVM-compatible networks. This server enables AI agents to interact with Ethereum, Optimism, Arbitrum, Base, Polygon, and many other EVM chains with a unified interface through 25 tools and 10 AI-guided prompts.
1010

1111
## 📋 Contents
1212

@@ -257,16 +257,17 @@ Get your free API key from:
257257

258258
### Server Configuration
259259

260-
The server uses the following default configuration:
260+
The HTTP server uses the following default configuration:
261261

262262
- **Default Chain ID**: 1 (Ethereum Mainnet)
263-
- **Server Port**: 3001
264-
- **Server Host**: 0.0.0.0 (accessible from any network interface)
263+
- **Server Port**: `3001` (`MCP_PORT`)
264+
- **Server Host**: `127.0.0.1` (`MCP_HOST`)
265+
- **Allowed Host headers**: Localhost hostnames (`MCP_ALLOWED_HOSTS`, comma-separated)
266+
- **Allowed Origin hostnames**: Localhost hostnames (`MCP_ALLOWED_ORIGINS`, comma-separated)
265267

266-
These values are hardcoded in the application. If you need to modify them, you can edit the following files:
268+
When binding to a non-local interface, explicitly configure the public hostnames accepted by `MCP_ALLOWED_HOSTS` and `MCP_ALLOWED_ORIGINS`. Values may be hostnames or origin URLs; validation is port-agnostic.
267269

268-
- For chain configuration: `src/core/chains.ts`
269-
- For server configuration: `src/server/http-server.ts`
270+
Chain defaults and RPC endpoints are configured in `src/core/chains.ts`.
270271

271272
## 🚀 Usage
272273

@@ -294,7 +295,7 @@ bun start
294295
bun dev
295296
```
296297

297-
Or start the HTTP server with SSE for web applications:
298+
Or start the stateless Streamable HTTP server for web applications:
298299

299300
```bash
300301
# Start the HTTP server
@@ -336,10 +337,6 @@ For a more portable configuration that you can share with your team or use acros
336337
"evm-mcp-server": {
337338
"command": "npx",
338339
"args": ["-y", "@mcpdotdirect/evm-mcp-server"]
339-
},
340-
"evm-mcp-http": {
341-
"command": "npx",
342-
"args": ["-y", "@mcpdotdirect/evm-mcp-server", "--http"]
343340
}
344341
}
345342
}
@@ -351,32 +348,45 @@ Place this file in your project's `.cursor` directory (create it if it doesn't e
351348
2. Version control your MCP setup
352349
3. Use different server configurations for different projects
353350

354-
### Example: HTTP Mode with SSE
351+
### Example: Streamable HTTP Mode
355352

356-
If you're developing a web application and want to connect to the HTTP server with Server-Sent Events (SSE), you can use this configuration:
353+
The HTTP entrypoint uses MCP `2026-07-28` stateless Streamable HTTP on `POST /mcp`. It does not mint `Mcp-Session-Id` values, and `GET /mcp` or `DELETE /mcp` return `405 Method Not Allowed`. HTTP is modern-only; stdio additionally serves legacy MCP `2025-11-25` clients through the SDK's version negotiation.
357354

358-
```json
359-
{
360-
"mcpServers": {
361-
"evm-mcp-sse": {
362-
"url": "http://localhost:3001/sse"
363-
}
364-
}
365-
}
366-
```
355+
Modern HTTP clients must send:
367356

368-
This connects directly to the HTTP server's SSE endpoint, which is useful for:
357+
- `Accept: application/json, text/event-stream`
358+
- `MCP-Protocol-Version: 2026-07-28`
359+
- `Mcp-Method: <json-rpc method>`
360+
- `Mcp-Name: <tool name, resource URI, or prompt name>` for `tools/call`, `resources/read`, and `prompts/get`
361+
- `params._meta.io.modelcontextprotocol/protocolVersion`
362+
- `params._meta.io.modelcontextprotocol/clientCapabilities`
369363

370-
- Web applications that need to connect to the MCP server from the browser
371-
- Environments where running local commands isn't ideal
372-
- Sharing a single MCP server instance among multiple users or applications
364+
Clients should also send `params._meta.io.modelcontextprotocol/clientInfo`. The final specification makes client identity optional, so the server accepts a request when that field is absent.
373365

374-
To use this configuration:
366+
Example discovery request:
375367

376-
1. Create a `.cursor` directory in your project root if it doesn't exist
377-
2. Save the above JSON as `mcp.json` in the `.cursor` directory
378-
3. Restart Cursor or open your project
379-
4. Cursor will detect the configuration and offer to enable the server(s)
368+
```bash
369+
curl -X POST http://127.0.0.1:3001/mcp \
370+
-H 'Content-Type: application/json' \
371+
-H 'Accept: application/json, text/event-stream' \
372+
-H 'MCP-Protocol-Version: 2026-07-28' \
373+
-H 'Mcp-Method: server/discover' \
374+
--data '{
375+
"jsonrpc": "2.0",
376+
"id": "discover-1",
377+
"method": "server/discover",
378+
"params": {
379+
"_meta": {
380+
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
381+
"io.modelcontextprotocol/clientInfo": {
382+
"name": "example-client",
383+
"version": "1.0.0"
384+
},
385+
"io.modelcontextprotocol/clientCapabilities": {}
386+
}
387+
}
388+
}'
389+
```
380390

381391
### Example: Using the MCP Server in Cursor
382392

@@ -632,7 +642,9 @@ mcp-evm-server/
632642
├── src/
633643
│ ├── index.ts # Main stdio server entry point
634644
│ ├── server/ # Server-related files
635-
│ │ ├── http-server.ts # HTTP server with SSE
645+
│ │ ├── http-server.ts # Stateless Streamable HTTP server
646+
│ │ ├── protocol.ts # Shared protocol metadata
647+
│ │ ├── stdio-server.ts # SDK-native dual-era stdio entry
636648
│ │ └── server.ts # General server setup
637649
│ ├── core/
638650
│ │ ├── chains.ts # Chain definitions and utilities
@@ -662,7 +674,7 @@ To modify or extend the server:
662674
2. Register new tools in `src/core/tools.ts`
663675
3. Register new resources in `src/core/resources.ts`
664676
4. Add new network support in `src/core/chains.ts`
665-
5. To change server configuration, edit the hardcoded values in `src/server/http-server.ts`
677+
5. Configure the HTTP listener with `MCP_PORT`, `MCP_HOST`, `MCP_ALLOWED_HOSTS`, and `MCP_ALLOWED_ORIGINS`
666678

667679
## 📄 License
668680

bin/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const require = createRequire(import.meta.url);
1313
const args = process.argv.slice(2);
1414
const httpMode = args.includes('--http') || args.includes('-h');
1515

16-
console.log(`Starting EVM MCP Server in ${httpMode ? 'HTTP' : 'stdio'} mode...`);
16+
console.error(`Starting EVM MCP Server in ${httpMode ? 'HTTP' : 'stdio'} mode...`);
1717

1818
// Determine which file to execute
1919
const scriptPath = resolve(__dirname, '../build', httpMode ? 'http-server.js' : 'index.js');
@@ -49,4 +49,4 @@ try {
4949
console.error('Please try reinstalling the package or contact the maintainers.');
5050
console.error(error);
5151
process.exit(1);
52-
}
52+
}

0 commit comments

Comments
 (0)