cortex

cortex-docsMIT活跃维护

从 OpenAPI、GraphQL、gRPC 等接口描述文件自动生成交互式 API 文档、带类型的 SDK 和 MCP 服务器,省去手写文档和客户端的重复劳动。

Cortex - Generates interactive API documentation, typed SDKs, and MCP servers from OpenAPI, AsyncAPI, GraphQL, gRPC, OpenRPC, and Markdown.

v0.1.36发布于 2026-09-28 08:21 UTC3,294star +1 / 7 天158fork同步于 2026-11-10 05:40 UTC

怎么上手

由 README 提炼,执行前请确认
mkdir petstore && cd petstore
npm install --global @cortex-docs/cli
cortex init petstore
cortex docs serve
硬件要求按 README 说明

README 未说明;仅要求 Node.js 20 或更高、npm 10 或更高,部分生成的 SDK 需目标语言自身的编译器或包管理器。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把 API 规范与 Markdown 一次性生成交互文档、类型化 SDK 和 MCP 服务器

从 OpenAPI、GraphQL、gRPC 等接口描述文件自动生成交互式 API 文档、带类型的 SDK 和 MCP 服务器,省去手写文档和客户端的重复劳动。

核心能力

  • 用一份 cortex.config.yml 声明所有 API 源并统一生成
  • 从 OpenAPI、AsyncAPI、GraphQL、gRPC、OpenRPC 生成类型化 SDK
  • 生成带类型工具与内嵌规范的 MCP 服务器供 AI 代理调用
  • 合并同语言同包名的多个规范到一个 SDK
  • 用稀疏 Eta 模板覆盖只改需要定制的输出

容易踩的坑

默认开发服务器端口为 3012,访问 http://localhost:3012;生成的 MCP 服务器需进入输出目录执行 npm install 和 npm run build 后才能启动;静态文档部署需让托管方把 /docs/quickstart 这类路径解析到对应 .html 文件。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v0.1.36
  1. v0.1.36Cortex Docs v0.1.36最新正式版2026-09-28 · 2026-09-28 08:21 UTC

    New Features

    • Deploy free documentation hosting for public GitHub repositories with cortex deploy, publishing your existing Markdown to a *.cortexdocs.dev subdomain.
    • Serve a live MCP server directly from a public repository with cortex mcp-serve https://github.com/OWNER/REPO, without a local checkout.
    • Documentation sites are now published through Cloudflare Static Assets for direct, low-latency delivery of hosted docs.

    Bug Fixes

    • Fixed in-page links to Markdown headings so they scroll to the correct section in the hosted documentation site, even before content has fully loaded.
    • Removed a conflicting cache-control header on static hosted assets that could cause stale or inconsistent caching behavior.

    Improvements

    • None.
  2. v0.1.35Cortex Docs v0.1.352026-09-22 · 2026-09-22 14:53 UTC
    查看更新说明

    New Features

    • None.

    Bug Fixes

    • None.

    Improvements

    • Documented the primaryColor configuration option in the README, showing how to set the documentation accent color as a six-digit hex value.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Cortex combines OpenAPI, AsyncAPI, GraphQL, Protocol Buffer, OpenRPC, and Markdown sources. Developers get interactive documentation, applications get typed SDKs, and AI agents get an MCP server with project context.

    If Cortex helps your team, star this repository to support its development.

    Try Cortex in 60 seconds

    Start a local demo:

    mkdir petstore
    cd petstore
    npm install --global @cortex-docs/cli
    cortex init petstore
    cortex docs serve
    

    Open http://localhost:3012. Press Ctrl+C to stop the server.

    We love open source

    Keep your Markdown in Git. Add cortex.config.yml to the default branch of your public GitHub repository, then run:

    npx -y @cortex-docs/cli deploy https://github.com/OWNER/REPO
    npx -y @cortex-docs/cli mcp-serve https://github.com/OWNER/REPO
    

    The first command publishes a free documentation site at PROJECT.cortexdocs.dev. The second connects AI clients to current documentation through local MCP.

    Deploy requires repository write access. MCP works with public read access and checks for changes before each request.

    See the open source hosting guide for configuration, custom domains, automatic updates, and limits.

    Features

    • Generate SDKs for TypeScript, Python, Go, Java, Kotlin, Ruby, PHP, C#, Rust, C++, and C.
    • Combine multiple specification files in one generated SDK.
    • Generate HTTP, WebSocket, GraphQL, gRPC, and JSON-RPC clients.
    • Build static HTML documentation with interactive API reference pages.
    • Generate an MCP server with typed tools, embedded specifications, SDK guides, and project documentation for AI agents.
    • Add Markdown pages, SDK guides, and all API specifications to the MCP server.
    • Customize generated output with sparse Eta template overrides.
    • Publish generated packages and MCP servers to language registries and GitHub repositories.

    Unlimited specs. Multiple ways to use it.

    Generate interactive docs for exploration, typed SDKs for integration, and MCP servers for AI agents.

    TaskSplit toolchainCortex Docs
    ConfigurationConfigure SDK, documentation, and MCP generatorsDeclare all API sources in one project configuration
    GenerationCoordinate separate commands and output directoriesGenerate all configured outputs with one command
    CustomizationMaintain templates for each generatorOverride only the required Eta templates
    PublishingMaintain a release process for each packageReview one publish plan for registries and GitHub
    Developer interfaceKeep guides separate from API referencesCombine Markdown, API references, and SDK guides
    Agent interfaceMaintain MCP servers and context separatelyGenerate MCP servers with specifications, SDK guides, and project documentation

    Requirements

    • Node.js 20 or later
    • npm 10 or later

    Some generated SDKs require the normal compiler or package manager for their target language.

    Configuration

    cortex init creates cortex.config.yml. Relative paths start from the directory that contains this file.

    project: my-api
    title: My API Docs
    logo: ./assets/logo.svg
    theme: system
    primaryColor: '#ffffff'
    custom_head_html: |-
      <meta name="theme-color" content="#ffffff">
      <link rel="stylesheet" href="/assets/custom.css">
    
    sources:
      - title: REST API
        type: openapi-spec
        spec: ./specs/openapi.yaml
        intro: ./docs/rest.md
        languages:
          - language: typescript
            package_name: '@my-org/my-api'
          - language: python
            package_name: my-api
    
      - title: Realtime API
        type: asyncapi-spec
        spec: ./specs/asyncapi.yaml
        languages:
          - language: typescript
            package_name: '@my-org/my-api'
    
      - title: GraphQL API
        type: graphql-spec
        spec: ./specs/schema.graphql
        endpoint: https://api.example.com/graphql
        languages:
          - language: typescript
            package_name: '@my-org/my-api'
    
    output:
      base_dir: ./generated
    
    docs:
      - section: Get started
        sources:
          - title: Quickstart
            document: ./docs/quickstart.md
    
    mcp:
      package_name: '@my-org/my-api-mcp'
    

    primaryColor sets the documentation accent color as a six-digit hex value.

    custom_head_html adds trusted HTML to every documentation page. This field supports metadata, stylesheets, and analytics scripts.

    Store local head resources in the project assets directory. Cortex serves these files from /assets/*.

    Cortex does not sanitize this value. Add only HTML that you trust.

    Add ?appearance=dark or ?appearance=light to any documentation URL to select its initial appearance. The parameter takes priority over the project theme and the visitor's stored preference.

    For example, /docs/quickstart?appearance=dark opens the quickstart in dark mode. The theme button can change the appearance after the page loads.

    Sources that use the same language and package_name are merged into one SDK. Cortex rejects duplicate operation and type names that would make a merge ambiguous.

    See the configuration reference for all fields.

    Commands

    CommandResult
    cortex init <name>Create a project and sample files.
    cortex validateValidate the config and every API source.
    cortex generateGenerate configured SDKs and the MCP server.
    cortex generate --language typescriptGenerate one configured language.
    cortex generate --dry-runShow planned output without writing files.
    cortex docs serveStart the development server and watch project files.
    cortex docs build --output .cortex/docsBuild static HTML documentation.
    cortex mcp generateGenerate only the MCP server.
    cortex publish --dry-runCheck package publication without uploading.
    cortex publishPublish enabled generated packages.

    Protocol support

    SourceGenerated SDKDocumentationGenerated MCP server
    OpenAPIREST clientsInteractive API referenceCallable tools and embedded specs
    AsyncAPIWebSocket clientsChannel and message referencePayload-preparation tools and specs
    GraphQL SDLQuery, mutation, and subscription clientsOperation and type referenceCallable tools and embedded schema
    Protocol BufferUnary and streaming gRPC clientsService and message referenceEmbedded .proto resources
    OpenRPCJSON-RPC clientsMethod and schema referenceCallable tools and embedded specs

    The generated MCP server does not call gRPC methods. It exposes Protocol Buffer files as MCP resources so an agent can inspect the service contract.

    Production documentation

    The build command exports the documentation as static HTML, CSS, JavaScript, and data files.

    cortex docs build --output .cortex/docs
    

    Deploy the output directory to a static web host. Configure the host to resolve page URLs such as /docs/quickstart to /docs/quickstart.html.

    The deployed site needs no Node.js server or access to the original configuration and specifications. Rebuild the site after source changes. Use cortex docs serve for a local preview with file watching.

    MCP output

    cortex mcp generate --output .cortex/mcp-server
    cd .cortex/mcp-server
    npm install
    npm run build
    npm start
    

    The generated package contains local copies of every configured specification. It also embeds configured Markdown and generated SDK README files as tools.

    Packages

    The release workflow publishes @cortex-docs/cli and @cortex-docs/mcp. The CLI tarball includes the internal runtime workspaces.

    PackageDistributionPurpose
    @cortex-docs/clinpmCommand-line interface and project workflow
    @cortex-docs/mcpnpmMCP server for the Cortex documentation
    @cortex-docs/coreIncluded in CLIConfiguration loader and specification parsers
    @cortex-docs/codegenIncluded in CLISDK generation engine and language templates
    @cortex-docs/mcp-genIncluded in CLIMCP server generator
    @cortex-docs/docs-uiIncluded in CLIDocumentation runtime used by the CLI

    Documentation

    Contributing and security

    Read CONTRIBUTING.md and DEVELOPMENT.md before you open a pull request.

    Report vulnerabilities through the private process in SECURITY.md.

    License

    Cortex Docs is available under the MIT License.

    If Cortex saves you time, give the repository a star. It helps more developers find the project.