About Openapi MCP Server
Openapi MCP Server is an MCP server published by h2562961224 in the Developer Tools category: 把使用openapi作为接口文档的用springboot构建的web应用转成mcp server.
The repository has 2 stars and 0 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/h2562961224/openapi-mcp-serverThis 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 Openapi MCP Server
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 7 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- !License declaredNo license file. Legally you have no right to use it in a product.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- !Dependencies pinnedNo lockfile. Installs can pull different code over time.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
概述
能直接让使用openapi(swagger)作为接口文档的接口支持mcp,应用成为一个mcp server。
- 多Session支持
- 认证支持
价值在于有mcp client(如cursor,claude desktop等)就能完成业务操作,而不用写前端页面(Claude Sonnet 3.7实测无敌) 另外未来一定有基于AI的超级app出现。在基于语言的新的交互方式下,我们只需要写后端接口就行了
要求
- Java 17+
- SpringBoot
- SpringMVC
快速开始
- 加入依赖,mcp原生依赖
<dependency>
<groupId>io.modelcontextprotocol.sdk</groupId>
<artifactId>mcp-spring-webmvc</artifactId>
<version>0.7.0</version>
</dependency>
-
复制代码
InternalWebMvcSseServerTransport.javaMcpConfig.javaRestApiToolProvider.javaUserContextSetter.java -
实现
UserContextSetter接口 Demo
@Component
@AllArgsConstructor
public class MyUserContextSetter implements UserContextSetter{
private JwtConfig jwtConfig;
@Override
public void set(String auth) {
UserContext.set(jwtConfig.getUserContextFromTokenWithoutException(auth));
}
@Override
public void clear() {
UserContext.clear();
}
}
-
补充其他基础设施(拦截器等)以满足业务需求
-
客户端Demo
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
const transport = new SSEClientTransport(new URL("http://localhost:8080/mcp/sse/eyJhbGciOiJIUzI1NiJ9.eyJ0ZW5hbnRfaWQiOjIsImlzX2FkbWluIjpmYWxzZSwic3ViIjoiMiIsImlhdCI6MTc0MzA4MTE5MiwiZXhwIjoxNzQzMTY3NTkyfQ.newz2wj0l5nWk1U_lHNg575bi1FubWSLXqji4o2W-P0"));
const client = new Client(
{
name: "MCP Server",
version: "1.0.0"
}
);
await client.connect(transport);
const tools = await client.listTools();
// List all tools
console.log("Tools: ", JSON.stringify(tools));
// Call a tool
const result = await client.callTool({
name: "TenantController.pageUser",
arguments: {
current: 1,
pageSize: 10
}
});
console.log("Result: ", JSON.stringify(result));
README fetched from the repository 7 days ago. The original is authoritative.