npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@faapi/schema

v3.1.0

Published

Schema introspection for faapi — expose API schema to AI assistants via MCP

Downloads

2,122

Readme

@faapi/schema

将 faapi 路由 schema 通过 MCP 协议暴露给 AI 助手

@faapi/schema 是 faapi 的扩展包,基于 @faapi/mcp(纯手写 MCP Server SDK)构建 MCP Server,通过 Streamable HTTP transport 在 /mcp 端点暴露路由 schema,让 AI 助手(如 Claude、Codex)能查询你的 API 路由结构、参数类型,无需阅读源代码即可理解接口定义。

不依赖 @modelcontextprotocol/sdk,MCP 协议层完全由 @faapi/mcp 实现。

安装

pnpm add @faapi/schema
# 或
npm install @faapi/schema

要求 Node.js >= 24。

快速开始

faapi.config.ts 中声明插件:

export default {
  plugins: ['@faapi/schema'],
} satisfies FaapiConfig;

启动 dev server 后,MCP 端点自动挂载到 /mcp 路径。插件声明即为开关——不需要时从 plugins 数组移除即可,也可用 { package: '@faapi/schema', enable: false } 临时禁用。

MCP 工具

| 工具名 | 功能 | |--------|------| | list_routes | 列出所有 HTTP 路由(方法、路径、是否动态路由) | | get_route_schema | 获取单个路由的详细输入参数(名称、类型、是否必填) | | get_api_schema | 获取所有路由的完整 schema(类似 OpenAPI) |

MCP 客户端配置

AI 助手通过 Streamable HTTP 连接到 http://localhost:3000/mcp(端口取决于 PORT 环境变量)。以支持 HTTP transport 的 MCP 客户端为例:

{
  "mcpServers": {
    "faapi": {
      "url": "http://localhost:3000/mcp"
    }
  }
}

连接流程:POST /mcp 发送 initialize 请求 → 从响应 Mcp-Session-Id header 获取会话 ID → 后续 tools/listtools/call 请求携带该 header → DELETE /mcp(带 session header)销毁会话。

许可证

MIT