
Model Context Protocol SDK 在 Lua for OpenResty 中实现
概览
- [x] 传输 - [x] 标准 - [x] 可流式HTTP - [x] WebSocket(非规范) - [x] 协议 - [x] 生命周期 - [x] 提示 - [x] 资源 - [x] 工具 - [x] 根 - [x] 采样 - [x] 引发 - [x] 工具 - [x] 分页 - [x] 进展 - [x] 取消 - [x] 完成 - [x] 日志 - [x] Ping 一个简单的服务器,展示提示词、资源和工具: 语法:server, err = mcp.server(transport[, options]) 创建一个包含特定传输的MCP服务器会话(目前这里仅有mcp.transport.stdio)和选项。 成功调用返回MCP服务器会话。否则返回nil和描述错误的字符串。 * mcp.transport.stdio * mcp.transport.websocket 1. 可选字段标题适用于用户界面和终端用户上下文——优化为易于人类阅读且易于理解,即使是不熟悉领域特定术语的人也能理解。如果未提供,应使用该名称进行显示;2.
概述(AI 翻译)
模型上下文协议(MCP) 用 Lua 实现的 SDK,用于 OpenResty。
状态
制作准备就绪。
目录
- 功能特征
- 快速启动
- 服务器API
- mcp.server
- mcp.transport.streamable_http.endpoint
- 服务器:运行
- 服务器:注册
- 服务器:unregister_*
- 服务器:资源_updated
- 服务器:替换_*
- 服务器:列表_roots
- 服务器:创建_message
- 服务器:Elicit
- server:log
- 服务器:ping
- 服务员:等一下_background_tasks
- 服务器:关闭
- 编写MCP客户端
- 客户端API
- MCP.client
- client:initialize
- 客户:等等_background_tasks
- 客户端:关闭
- 客户:曝光_roots
- 客户名单_prompts
- 客户:get_prompt
- 客户名单_resources
- 客户名单_resource_templates
- 客户端:已阅读_resource
- 客户端:订阅_resource
- 客户端:取消订阅_resource
- 客户:列表_tools
- 客户:呼叫_tool
- 客户:提示_complete
- 客户:资源_complete
- 客户:set_log_level
- 客户端:ping
- 已知问题
- 取消使用stdio传输服务器的请求
- 许可证
特色
- [x] 运输
- [x] 标准
- [x] 可流式HTTP
- [x] WebSocket (非规范)
- [x] 协议
- [x] 生命周期
- [x] 提示
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
lua-resty-mcp
Model Context Protocol (MCP) SDK implemented in Lua for OpenResty.
Status
Production ready.
Table of Contents
- Features
- Quickstart
- Server APIs
- Writing MCP Clients
- Client APIs
- mcp.client
- client:initialize
- client:wait_background_tasks
- client:shutdown
- client:expose_roots
- client:list_prompts
- client:get_prompt
- client:list_resources
- client:list_resource_templates
- client:read_resource
- client:subscribe_resource
- client:unsubscribe_resource
- client:list_tools
- client:call_tool
- client:prompt_complete
- client:resource_complete
- client:set_log_level
- client:ping
- Known Issues
- License
Features
- [x] Transports
- [x] stdio
- [x] Streamable HTTP
- [x] WebSocket (non-specification)
- [x] Protocols
- [x] Lifecycle
- [x] Prompts
- [x] Resources
- [x] Tools
- [x] Roots
- [x] Sampling
- [x] Elicitation
- [x] Utilities
- [x] Pagination
- [x] Progress
- [x] Cancellation
- [x] Completion
- [x] Logging
- [x] Ping
Quickstart
A simple server demonstrating prompts, resources, tools:
-- Import lua-resty-mcp module
local mcp = require("resty.mcp")
-- Create an MCP server session with stdio transport
local server = assert(mcp.server(mcp.transport.stdio, {}))
-- Register a prompt
assert(server:register(mcp.prompt("echo", function(args)
return "Please process this message: "..args.message
end, {
description = "Create an echo prompt",
arguments = {
message = {required = true}
}
})))
-- Register a resource template
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →