About Express MCP Server Ai2wallet
Express MCP Server Ai2wallet is an MCP server in the Blockchain category: ai2wallet express mcp server starter kit. It has been installed 0 times through Conduid.
Install
git clone https://github.com/jeanlouis-dev/express-mcp-server-ai2walletThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Express MCP Server Ai2wallet
Powered by Claude · Grounded in docs
Security checks
- ·README presentNot checked yet.
- ·License declaredNot checked yet.
- ·Tests presentNot checked yet.
- ·Dependencies pinnedNot checked yet.
- ·No dynamic code executionNot checked yet.
- ·Scoped permissionsNot checked yet.
README
x402 Express MCP Server Example
Express.js MCP server demonstrating how to protect API endpoints with a paywall using the ai2wallet-sdk middleware.
Prerequisites
- Node.js v20+ (install via nvm)
- Valid EVM, SVM and STELLAR addresses for receiving payments
- URL of a facilitator supporting the desired payment network, see facilitator list
Setup
- Copy
.env-localto.env:
cp .env-local .env
and fill required environment variables:
FACILITATOR_URL- Facilitator endpoint URLEVM_ADDRESS- Ethereum address to receive paymentsSVM_ADDRESS- Solana address to receive paymentsSTELLAR_ADDRESS- Stellar address to receive paymentsRESOURCE_SERVER_URL- Your endpoint Base URLENDPOINT_PATH- Your route path
- Install all packages
cd express-mcp-server
npm install
- Run the server
npm run dev
Create MCP server and register tools
import { ai2walletFetcher, McpServer, z } from 'ai2wallet-sdk/server';
const baseURL = process.env.RESOURCE_SERVER_URL;
const endpointPath = process.env.ENDPOINT_PATH;
const server = new McpServer({
name: "Ai2wallet x402 MCP Server Demo",
version: "1.0.0",
});
server.registerTool("get-weather", {
title: "Get Weather",
description: "Get current weather for a location",
inputSchema: z.object({
location: z.string().describe('City name'),
})
},
async ({ location }) => {
const response:any = await ai2walletFetcher(server,baseURL,endpointPath,{ location });
return {
content: [{ type: "text", text: response.data.message }, response.uiResource]
};
}
);
Handle Endpoints
// Realtime Bidirectional Communication
app.use('/api/trpc', ai2walletRPC());
// Handle POST requests for client-to-mcpserver communication
app.post('/mcp', async (req, res) => {
//your code logic here
});
// configure the payment middleware with your routes
app.use(
paymentMiddleware(
{
"GET /your-endpoint": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
payTo: svmAddress,
},
{
scheme: "exact",
price: "$0.3",
network: "stellar:testnet",
payTo: stellarAddress,
},
{
scheme: "exact",
price: "$0.5",
network: "eip155:84532",
payTo: evmAddress,
}
],
description: "Your endpoint description",
mimeType: "application/json",
},
},
resourceServer,
),
);
// Then define your routes as normal
app.get("/your-endpoint", (req, res) => {
res.send({
message: // your message reponse
structuredOutput // optional structured output
})
});
Network identifiers use CAIP-2 format, for example:
eip155:84532— Base Sepoliaeip155:8453— Base Mainnetsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1— Solana Devnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp— Solana Mainneteip155:1328— Sei Testneteip155:1329— Sei Mainneteip155:80002— Polygon Amoyeip155:137— Polygon Mainnetstellar:testnet— Stellar Testnetstellar:pubnet— Stellar Mainnet
x402ResourceServer Config
The x402ResourceServer uses a builder pattern to register payment schemes that declare how payments for each network should be processed:
import {
x402ResourceServer,
ExactEvmScheme,
ExactSvmScheme
ExactStellarScheme,
} from 'ai2wallet-sdk/server';
const resourceServer = new x402ResourceServer(facilitatorClient)
.register("eip155:*", new ExactEvmScheme()) // All EVM chains
.register("solana:*", new ExactSvmScheme()) // All SVM chains
.register("stellar:*", new ExactStellarScheme()) // All STELLAR chains
Facilitator Config
The HTTPFacilitatorClient connects to a facilitator service that verifies and settles payments on-chain:
import { HTTPFacilitatorClient } from 'ai2wallet-sdk/server';
const facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });
// Or use multiple facilitators for redundancy
const facilitatorClient = [
new HTTPFacilitatorClient({ url: primaryFacilitatorUrl }),
new HTTPFacilitatorClient({ url: backupFacilitatorUrl }),
];
README mirrored from the source repository 4 months ago. The original is authoritative.