返回市场
伊莉西娅-MCP-启动器

伊莉西娅-MCP-启动器

作者:kerlos7 星标更新:2025-06-22

项目介绍

Elysia MCP Starter

使用Elysia和Bun运行时构建MCP(模型上下文协议)服务器的起始模板。

此起始模板基于elysia-mcp插件,该插件提供了全面的ElysiaJS集成,支持HTTP传输的模型上下文协议。

目的

此仓库提供了一个创建可与Claude Desktop、Cody或其他兼容MCP的应用程序一起使用的MCP服务器的基础。它展示了如何实现:

  • 工具:可以由LLMs调用的函数(例如计算器)
  • 提示:可重用的提示模板
  • 资源:可以被LLMs访问的动态数据源

目录结构

elysia-mcp-starter/
├── src/
│   ├── index.ts          # 主应用程序入口点
│   ├── tools/            # MCP工具(可由LLMs调用的函数)
│   │   └── calculate.ts  # 示例计算器工具
│   ├── prompts/          # MCP提示模板
│   │   └── hello.ts      # 示例问候提示
│   └── resources/        # MCP资源(动态数据源)
│       └── news.ts       # 示例新闻资源
├── package.json          # 项目依赖项和脚本
├── tsconfig.json         # TypeScript配置
└── README.md            # 此文件

开始使用

方案1:使用Bun Create(推荐)

# 从起始模板创建新项目
bun create https://github.com/kerlos/elysia-mcp-starter my-mcp-project

# 导航到项目
cd my-mcp-project

# 安装依赖项
bun install

# 启动开发服务器
bun run dev

方案2:克隆仓库

  1. 克隆或使用此模板:

    git clone https://github.com/kerlos/elysia-mcp-starter.git
    cd elysia-mcp-starter
    
  2. 安装依赖项:

    bun install
    
  3. 启动开发服务器:

    bun run dev
    

MCP服务器将在以下地址可用:

  • 服务器:http://localhost:3000
  • MCP端点:http://localhost:3300/mcp

开发

  • 开发服务器bun run dev(带自动重新加载)
  • 生产服务器bun run start
  • 检查MCP服务器bun run inspect(打开MCP检查器)

添加新组件

工具

src/tools/中添加新的工具,并在src/index.ts中注册它们:

import { registerYourTool } from './tools/your-tool';
// ... 在setupServer中:
registerYourTool(server);

提示

src/prompts/中添加新的提示,并在src/index.ts中注册它们:

import { registerYourPrompt } from './prompts/your-prompt';
// ... 在setupServer中:
registerYourPrompt(server);

资源

src/resources/中添加新的资源,并在src/index.ts中注册它们:

import { registerYourResource } from './resources/your-resource';
// ... 在setupServer中:
registerYourResource(server);

使用LLM客户端

配置您的兼容MCP客户端连接到http://localhost:3000/mcp以访问此服务器提供的工具、提示和资源。

MCP客户端配置

在您的MCP客户端配置文件中添加以下配置:

对于Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "elysia-mcp-starter": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

对于Cursor (~/.cursor/mcp.json):

{
  "mcpServers": {
    "elysia-mcp-starter": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

对于Cody(VS Code设置):

{
  "cody.experimental.mcp.servers": {
    "elysia-mcp-starter": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

"elysia-mcp-starter"替换为您首选的服务器名称,并根据需要更新URL。

许可证

本项目采用MIT许可证——详情见LICENSE文件。