Integrations
Implements the MCP server using TypeScript, as evidenced by the core files server.ts, main.ts, and browser-transport.ts
Used for development and building of the MCP server application
Provides the runtime environment for the MCP server to run within a web browser
WASM MCP Server
A proof-of-concept implementation of a Model Context Protocol (MCP) server that runs in WebAssembly (WASM) within a web browser. This project demonstrates the integration of MCP tools and resources in a browser environment.
Features
Calculator Tool
- Performs basic arithmetic operations (addition, subtraction, multiplication, division)
- Input validation and error handling
- Real-time calculation results
Storage System
- Key-value storage functionality
- Set and retrieve values using string keys
- Persistent storage within the browser session
- Template-based resource handling
Technical Implementation
Server Components
server.ts
: Core MCP server implementation with tool and resource definitionsmain.ts
: Client-side integration and UI interaction handlingbrowser-transport.ts
: Custom transport layer for browser communication
Architecture
- Uses the Model Context Protocol SDK for server implementation
- Implements a custom browser transport layer
- Tools are registered with callback functions
- Resources use template paths with parameter substitution
Key Concepts
- Tools
- Registered using
server.tool()
- Execute via callback functions
- Schema validation using Zod
- Registered using
- Resources
- Template-based paths (e.g.,
storage://{key}
) - Accessed via
readCallback
- Parameterized resource handling
- Template-based paths (e.g.,
Usage
Calculator
- Select an operation (add, subtract, multiply, divide)
- Enter two numbers
- Click "Calculate" to see the result
- Error handling for invalid inputs and division by zero
Storage
- Enter a key and value in the respective fields
- Click "Set Storage" to store the value
- Enter a key and click "Get Storage" to retrieve a value
- Feedback provided for successful operations and errors
Dependencies
- @modelcontextprotocol/sdk
- Zod (for schema validation)
- TypeScript
- Vite (for development and building)
Project Structure
Error Handling
- Server initialization errors
- Tool execution errors
- Resource access errors
- Input validation
- Transport layer errors
Future Enhancements
- Additional calculator operations
- Persistent storage across sessions
- Enhanced UI/UX
- Additional MCP tools and resources
- WASM optimization
Development
This is a proof-of-concept implementation demonstrating the feasibility of running an MCP server in a web browser using WebAssembly. The implementation focuses on demonstrating core MCP concepts while maintaining simplicity and clarity.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
This server enables running a Model Context Protocol in a web browser with functionalities including arithmetic operations and session-based key-value storage.
- Features
- Technical Implementation
- Usage
- Dependencies
- Project Structure
- Error Handling
- Future Enhancements
- Development
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that provides web content fetching and conversion capabilities.Last updated -4892JavaScriptMIT License
- AsecurityFlicenseAqualityA server that provides tools for performing basic arithmetic operations (addition, subtraction, multiplication, division) via the Model Context Protocol.Last updated -4JavaScript
- -securityFlicense-qualityA Model Context Protocol server built with Express.js that provides cryptographic tools including key pair generation, shared secret derivation, and message encryption/decryption.Last updated -160JavaScript
- -securityAlicense-qualityA Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.Last updated -2PythonMIT License