Skip to main content
Glama

WASM MCP Server

by beekmarks

WASM MCP 服务器

一个概念验证实现,用于在 Web 浏览器中以 WebAssembly (WASM) 运行的模型上下文协议 (MCP) 服务器。该项目演示了如何在浏览器环境中集成 MCP 工具和资源。

特征

计算器工具

  • 执行基本算术运算(加法、减法、乘法、除法)
  • 输入验证和错误处理
  • 实时计算结果

存储系统

  • 键值存储功能
  • 使用字符串键设置和检索值
  • 浏览器会话中的持久存储
  • 基于模板的资源处理

技术实现

服务器组件

  • server.ts :核心 MCP 服务器实现,包含工具和资源定义
  • main.ts :客户端集成和 UI 交互处理
  • browser-transport.ts :用于浏览器通信的自定义传输层

建筑学

  • 使用模型上下文协议 SDK 进行服务器实现
  • 实现自定义浏览器传输层
  • 工具已注册回调函数
  • 资源使用带有参数替换的模板路径

关键概念

  1. 工具
    • 使用server.tool()注册
    • 通过回调函数执行
    • 使用 Zod 进行模式验证
  2. 资源
    • 基于模板的路径(例如, storage://{key}
    • 通过readCallback访问
    • 参数化资源处理

用法

计算器

  1. 选择运算(加、减、乘、除)
  2. 输入两个数字
  3. 点击“计算”查看结果
  4. 无效输入和除以零的错误处理

贮存

  1. 在相应的字段中输入键和值
  2. 点击“设置存储”来存储值
  3. 输入密钥并单击“获取存储”以检索值
  4. 为成功操作和错误提供反馈

依赖项

  • @modelcontextprotocol/sdk
  • Zod(用于模式验证)
  • TypeScript
  • Vite(用于开发和建设)

项目结构

mcp-wasm-poc/ ├── src/ │ └── web/ │ ├── server.ts # MCP server implementation │ ├── main.ts # Client-side logic │ └── browser-transport.ts # Browser transport layer ├── index.html # Web interface └── package.json # Project dependencies

错误处理

  • 服务器初始化错误
  • 工具执行错误
  • 资源访问错误
  • 输入验证
  • 传输层错误

未来的增强功能

  • 附加计算器操作
  • 跨会话的持久存储
  • 增强的 UI/UX
  • 其他 MCP 工具和资源
  • WASM 优化

发展

这是一个概念验证实现,演示了使用 WebAssembly 在 Web 浏览器中运行 MCP 服务器的可行性。该实现侧重于演示 MCP 的核心概念,同时保持简洁明了。

-
security - not tested
F
license - not found
-
quality - not tested

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.

该服务器能够在 Web 浏览器中运行模型上下文协议,其功能包括算术运算和基于会话的键值存储。

  1. 特征
    1. 计算器工具
    2. 存储系统
  2. 技术实现
    1. 服务器组件
    2. 建筑学
    3. 关键概念
  3. 用法
    1. 计算器
    2. 贮存
  4. 依赖项
    1. 项目结构
      1. 错误处理
        1. 未来的增强功能
          1. 发展

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol server that provides web content fetching and conversion capabilities.
              Last updated -
              4
              89
              2
              JavaScript
              MIT License
              • Apple
            • A
              security
              F
              license
              A
              quality
              A server that provides tools for performing basic arithmetic operations (addition, subtraction, multiplication, division) via the Model Context Protocol.
              Last updated -
              4
              JavaScript
              • Apple
            • -
              security
              F
              license
              -
              quality
              A 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 -
              160
              JavaScript
            • -
              security
              A
              license
              -
              quality
              A 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 -
              2
              Python
              MIT License
              • Apple

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/beekmarks/mcp-wasm'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server