CornMCP 标志

CornMCP

社区
yuki-20

CornMCP is an open-source mono repo that gives AI coding agents (Antigravity, Cursor, Claude Code, Codex), token-saving access to your codebase through the Model Context Protocol (MCP).

发布者yuki-20
代码仓库CornMCP
语言TypeScript
复刻数
10
星标数
67
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    CornMCP 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 67 个星标和 10 个复刻。

🌽 CornMCP

The AI Agent Intelligence Platform — MCP Server + Analytics Dashboard

Surgical code intelligence. Semantic memory. Quality enforcement. Stop burning tokens on full-file reads. Start extracting exactly what your agent needs.

Node.js TypeScript MCP License


What is CornMCP?

Corn Hub is a Model Context Protocol (MCP) server and real-time analytics dashboard that gives AI coding agents (Antigravity, Cursor, Claude Code, Codex) surgical access to your codebase through 18 specialized tools.

Instead of dumping entire files into the context window, CornMCP provides:

  • 🧠 Semantic Memory — Agents remember across sessions via vector search
  • 🔍 Native AST Engine — Real call graphs, type hierarchies, and symbol-level analysis via TypeScript Compiler API
  • 📋 Quality Gates — Plans must score ≥80% before execution
  • 📊 Live Analytics — Track every tool call, latency, and token savings
  • 🔄 Multi-Agent Awareness — Agents see each other's changes in real-time
  • 💾 Zero External Dependencies — No external services. Everything runs locally with SQLite.

Architecture

1. System Overview

How the three services connect and communicate.

How It Works

ConnectionProtocolDescription
IDE → corn-mcpJSON-RPC over HTTPAI agent sends tool calls via MCP SDK. Bearer token auth required.
corn-mcp → corn-apiREST HTTP (fetch)Tool handlers call Dashboard API endpoints for data persistence.
corn-mcp → SQLite vectorsDirect file I/OMemory and knowledge tools embed content and store vectors locally.
corn-mcp → Voyage AIHTTPS APIOptional: semantic embeddings for memory/knowledge search. Falls back to local hash if unavailable.
corn-api → SQLitesql.js (in-process)All data stored in ./data/corn.db — sessions, quality, code graph, analytics.
corn-web → corn-apiREST HTTP (fetch)Dashboard fetches data from :4000 API for real-time visualization.
TelemetryFire-and-forget POSTEvery tool call logs to /api/metrics/query-log for analytics dashboard.

2. MCP Request Lifecycle

What happens step-by-step when your AI agent calls a Corn Hub tool.

Key Details

  • Stateless: Each request creates a fresh McpServer instance — no session state on the server
  • Auth: Bearer token validated against API keys stored in corn-api database
  • Telemetry: Every tool call is logged (tool name, status, latency, input size) as fire-and-forget
  • Embedding Fallback: If Voyage AI is rate-limited or unavailable, auto-rotates models then falls back to local hash embeddings
  • Model Rotation: voyage-code-3 → voyage-4-large → voyage-4 → voyage-code-2 → voyage-4-lite

3. The 18 MCP Tools — Categories & Data Flow

Every tool grouped by category, showing what backend each one hits.

Tool Reference

#ToolCategoryBackendDescription
1corn_healthHealthAPISystem health — services, uptime, version
2corn_list_reposCodeAPI + ASTList indexed repositories with symbol counts
3corn_code_searchCodeAST → SQLiteHybrid vector/AST symbol search
4corn_code_readCodeFilesystemRead raw source code from indexed repos
5corn_code_contextCodeAST → SQLite360° symbol view: callers, callees, hierarchy
6corn_code_impactCodeAST → SQLiteBlast radius analysis with recursive CTE
7corn_cypherCodeAST → SQLiteCypher-to-SQL graph queries
8corn_detect_changesCodeGit + ASTUncommitted changes cross-referenced with graph
9corn_memory_storeMemoryVector DBStore agent memory with embedding
10corn_memory_searchMemoryVector DBSemantic similarity search over memories
11corn_knowledge_storeKnowledgeVector DBStore shared knowledge item
12corn_knowledge_searchKnowledgeVector DBSemantic search over knowledge base
13corn_plan_qualityQualityAPI SQLiteScore a plan against 8 criteria (must ≥80%)
14corn_quality_reportQualityAPI SQLiteSubmit 4-dimension quality report (must ≥80%)
15corn_session_startSessionAPI SQLiteBegin tracked work session
16corn_session_endSessionAPI SQLiteEnd session with summary and decisions
17corn_tool_statsAnalyticsAPI SQLiteView tool usage analytics and trends
18corn_changesAnalyticsAPI SQLiteCheck for recent commits by other agents

4. Data Flow — From Code to Intelligence

How your codebase becomes a queryable knowledge graph.

Symbol Extraction Details

Symbol KindExampleWhat's Captured
FunctioncreateLogger()Name, params, return type, file, lines, exported?, signature
ClassCornErrorName, extends, implements, methods, properties
InterfaceLoggerName, members, extends
TypeLogLevelName, definition
EnumHttpStatusName, members
VariableappName, type annotation, initializer

Edge Types

EdgeMeaningExample
callsFunction A calls Function Bstart() → getDb()
importsFile A imports from File Bindex.ts → @corn/shared-utils
extendsClass A extends Class BNotFoundError → CornError
implementsClass implements InterfaceLocalHashEmbeddingProvider → EmbeddingProvider

Performance: Corn Hub indexes itself (49 files) in ~2 seconds, extracting 965 symbols and 407 edges.


Project Structure

corn-hub/
├── apps/
│   ├── corn-api/              # Dashboard REST API (Hono + SQLite)
│   │   └── src/
│   │       ├── index.ts       # Server entry, health checks
│   │       ├── db/
│   │       │   ├── client.ts  # SQLite client (sql.js)
│   │       │   └── schema.sql # Database schema (code_symbols, code_edges, etc.)
│   │       ├── services/
│   │       │   └── ast-engine.ts  # 🆕 Native TypeScript Compiler API AST engine
│   │       └── routes/
│   │           ├── intel.ts      # Code intelligence (search, context, impact, cypher)
│   │           ├── indexing.ts   # Trigger AST analysis for projects
│   │           ├── analytics.ts  # Tool usage analytics
│   │           ├── knowledge.ts  # Knowledge base CRUD
│   │           ├── projects.ts   # Project management
│   │           ├── providers.ts  # LLM provider accounts
│   │           ├── quality.ts    # 4D quality reports
│   │           ├── sessions.ts   # Agent session tracking
│   │           ├── setup.ts      # System info
│   │           ├── stats.ts      # Dashboard metrics
│   │           ├── system.ts     # System metrics (CPU, memory)
│   │           ├── usage.ts      # Token usage tracking
│   │           └── webhooks.ts   # Webhook endpoints
│   │
│   ├── corn-mcp/              # MCP Server (18 tools)
│   │   └── src/
│   │       ├── cli.ts         # STDIO transport + telemetry interceptor
│   │       ├── index.ts       # Server factory + tool registration
│   │       ├── node.ts        # HTTP transport entry point
│   │       └── tools/
│   │           ├── analytics.ts   # corn_tool_stats
│   │           ├── changes.ts     # corn_changes, corn_detect_changes
│   │           ├── code.ts        # corn_code_search/read/context/impact, corn_cypher
│   │           ├── health.ts      # corn_health
│   │           ├── knowledge.ts   # corn_knowledge_search/store
│   │           ├── memory.ts      # corn_memory_search/store
│   │           ├── quality.ts     # corn_plan_quality, corn_quality_report
│   │           └── sessions.ts    # corn_session_start/end
│   │
│   └── corn-web/              # Analytics Dashboard (Next.js 16)
│       └── src/
│           ├── app/
│           │   ├── page.tsx       # Main dashboard
│           │   ├── quality/       # Quality reports & grade trends
│           │   ├── sessions/      # Agent session history
│           │   ├── usage/         # Token usage analytics
│           │   ├── knowledge/     # Knowledge base viewer
│           │   ├── projects/      # Project management
│           │   ├── installation/  # IDE setup guide
│           │   └── settings/      # Configuration
│           ├── components/
│           │   └── layout/        # Glassmorphic dashboard shell
│           └── lib/
│               └── api.ts         # API client
│
├── packages/
│   ├── shared-mem9/           # Vector DB + Embedding Provider
│   │   └── src/index.ts       # SQLite vector store, model rotation,
│   │                          # OpenAI/Voyage embeddings, hash fallback
│   ├── shared-types/          # Shared TypeScript interfaces
│   └── shared-utils/          # Logger, ID gen, error classes
│
├── infra/
│   ├── docker-compose.yml     # Optional Docker stack
│   ├── Dockerfile.corn-api
│   ├── Dockerfile.corn-mcp
│   ├── Dockerfile.corn-web
│   └── nginx-dashboard.conf
│
└── .agent/
    └── workflows/
        └── corn-quality-gates.md  # Mandatory AI quality workflow

Native AST Engine

Corn Hub includes a built-in TypeScript Compiler API engine that provides real code intelligence — no external services needed.

What It Extracts

CategoryDetails
SymbolsFunctions, classes, interfaces, types, enums, variables, methods, properties
EdgesFunction calls, imports, extends, implements
MetadataFile paths, line ranges, export status, signatures, JSDoc comments

How It Works

Local Project Directory
        │
        ▼
  collectFiles()          Recursively find all .ts/.tsx/.js/.jsx files
        │                 (skips node_modules, dist, .git, etc.)
        ▼
  ts.createProgram()      TypeScript Compiler API parses all files
        │
        ▼
  AST Walk                Extract symbols + build dependency edges
        │
        ▼
  SQLite Storage          INSERT into code_symbols + code_edges tables
        │
        ▼
  Query Functions         searchSymbols, getSymbolContext, getSymbolImpact,
                          executeCypher, getProjectStats

Capabilities

  • Call Graph: Who calls dbRun? → 8 callers across 5 files with exact line numbers
  • Impact Analysis: What breaks if I change createLogger? → Recursive CTE traces 6 downstream symbols
  • Cypher Queries: MATCH (n:class) RETURN n → Finds all 10 classes in the codebase
  • Import Mapping: Which files import from shared-utils? → Full dependency graph
  • Type Hierarchies: CornError → NotFoundError, UnauthorizedError, ValidationError

Self-Indexing Results (Corn Hub itself)

MetricValue
Files Analyzed49
Symbols Extracted965
Edges Built407
By Kind764 variables, 111 functions, 32 interfaces, 28 methods, 16 properties, 10 classes, 1 type
Analysis Time~2 seconds

MCP Tools Reference

Corn Hub exposes 18 tools via the Model Context Protocol:

🧠 Memory & Knowledge

ToolDescription
corn_memory_storeStore a memory for cross-session recall
corn_memory_searchSemantic search across all agent memories
corn_knowledge_storeSave reusable patterns, decisions, bug fixes
corn_knowledge_searchSearch the shared knowledge base

🔍 Code Intelligence (AST-Powered)

ToolDescription
corn_code_searchHybrid vector + AST search across the codebase
corn_code_readRead raw source from indexed repos with line ranges
corn_code_context360° view of a symbol: callers, callees, imports, hierarchy
corn_code_impactBlast radius analysis — recursive CTE on dependency edges
corn_cypherCypher-like queries translated to SQL against the code graph
corn_detect_changesAnalyze uncommitted changes + cross-reference with indexed symbols
corn_list_reposList all indexed repositories with symbol/edge counts

📋 Quality & Sessions

ToolDescription
corn_plan_qualityScore a plan against 8 criteria (must pass ≥80%)
corn_quality_reportSubmit 4D quality scores (Build, Regression, Standards, Traceability)
corn_session_startBegin a tracked work session
corn_session_endEnd session with summary, files changed, decisions
corn_changesCheck for recent changes from other agents

📊 Analytics & System

ToolDescription
corn_tool_statsView tool usage analytics, success rates, latency
corn_healthSystem health check — all services, embedding status

Mandatory Quality Workflow

Every task follows this enforced pipeline:

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  PHASE 0     │────▶│  PHASE 1     │────▶│  PHASE 2     │
│  Session     │     │  Planning    │     │  Execution   │
│  Start       │     │              │     │              │
│              │     │  Plan must   │     │  Build &     │
│ • tool_stats │     │  score ≥80%  │     │  implement   │
│ • changes    │     │  or REJECTED │     │              │
│ • memory     │     │              │     │              │
└──────────────┘     └──────────────┘     └──────┬───────┘
                                                  │
┌──────────────┐     ┌──────────────┐             │
│  PHASE 4     │◀────│  PHASE 3     │◀────────────┘
│  Session     │     │  Quality     │
│  End         │     │  Report      │
│              │     │              │
│ • knowledge  │     │  Score must  │
│ • memory     │     │  be ≥80/100  │
│ • end        │     │  or FAIL     │
│ • stats      │     │              │
└──────────────┘     └──────────────┘

Configure in .agent/workflows/corn-quality-gates.md.


Installation

One-Command Installer (Recommended)

bash
npx corn-install

The interactive installer will:

  1. Check for Docker, Node.js, Git, pnpm
  2. Install missing dependencies (with your permission)
  3. Clone the Corn Hub repository
  4. Configure Voyage AI API key for embeddings
  5. Build and start the Docker stack
  6. Configure your IDE (Antigravity, Claude Code, Cursor, VS Code, Codex, Windsurf)
  7. Verify all 18 MCP tools are working

After installation, run the live monitor dashboard:

bash
npx corn-install monitor

Prerequisites

  • Node.js 22+
  • pnpm 10+
  • Docker (required for running the full stack)

Quick Start (Manual)

bash
# Clone
git clone https://github.com/yuki-20/corn-hub.git
cd corn-hub

# Install dependencies
pnpm install

# Start the API backend
cd apps/corn-api && npx tsx src/index.ts

# In another terminal — start the MCP server (HTTP mode)
cd apps/corn-mcp && npx tsx src/node.ts

# In another terminal — start the dashboard
cd apps/corn-web && npx next dev
ServicePortDescription
corn-api:4000Hono REST API + SQLite + AST Engine
corn-mcp:8317MCP Gateway (HTTP transport)
corn-web:3000Next.js Dashboard

IDE Configuration

⚠️ Replace the path below with where YOU cloned corn-hub.

Antigravity / Codex (VS Code)

json
{
  "mcpServers": {
    "corn": {
      "command": "node",
      "args": ["/path/to/corn-hub/apps/corn-mcp/dist/cli.js"]
    }
  }
}

Cursor

  1. Settings → Features → MCP
  2. Click + Add new MCP server
  3. Name: corn · Type: command
  4. Command: node /path/to/corn-hub/apps/corn-mcp/dist/cli.js

Claude Code

bash
claude mcp add corn -- node /path/to/corn-hub/apps/corn-mcp/dist/cli.js
OSExample Path
WindowsC:\Users\You\corn-hub\apps\corn-mcp\dist\cli.js
macOS/Users/You/corn-hub/apps/corn-mcp/dist/cli.js
Linux/home/You/corn-hub/apps/corn-mcp/dist/cli.js

Indexing Your Project

Once the API is running, create a project and index it:

bash
# Create a project pointing to your local repo
curl -X POST http://localhost:4000/api/projects \
  -H "Content-Type: application/json" \
  -d '{"name":"My Project","gitRepoUrl":"/path/to/your/repo"}'

# Trigger AST analysis (returns projectId from above)
curl -X POST http://localhost:4000/api/intel/analyze \
  -H "Content-Type: application/json" \
  -d '{"projectId":"proj-XXXXX"}'

Dashboard (Optional Docker)

bash
docker compose -f infra/docker-compose.yml up -d --build

Open http://localhost:3000 → the Corn Hub Analytics Dashboard.

Note: Docker is optional. All services run natively with Node.js for development.


Environment Variables

VariableDefaultDescription
OPENAI_API_KEY—Voyage AI / OpenAI API key for embeddings
OPENAI_API_BASEhttps://api.voyageai.com/v1Embedding API base URL
MEM9_EMBEDDING_MODELvoyage-code-3Primary embedding model
MEM9_EMBEDDING_DIMS1024Embedding dimensions
MEM9_FALLBACK_MODELSvoyage-4-large,voyage-4,voyage-code-2,voyage-4-liteFallback model rotation chain
DASHBOARD_API_URLhttp://localhost:4000Dashboard API URL

Model Rotation

When the primary model hits rate limits (429), Corn Hub automatically rotates through fallback models:

voyage-code-3 → voyage-4-large → voyage-4 → voyage-code-2 → voyage-4-lite
 (best code)     (largest gen)    (gen-4)    (older code)    (lightweight)

Each model gets 3 retries with exponential backoff before rotating. Set MEM9_FALLBACK_MODELS to customize.


Real Token Savings (Measured Data)

These numbers are from actual usage, not theoretical projections.

During a live 29-call session on the Corn Hub codebase (55 files, 217 KB):

MetricValue
Avg tokens per tool call137 tokens
Avg tokens per file read (standard)~1,500 tokens
Tool call overhead (29 calls)3,966 tokens
File re-reads prevented~34,600 tokens saved

Savings by Codebase Size

Repo SizeStandard AgentWith Corn HubSavings
Small (55 files)~195K tokens~135K tokens30%
Medium (200 files)~450K tokens~180K tokens60%
Large (1000 files)~1.2M tokens~250K tokens79%
Enterprise (5000+)~3M+ tokens~400K tokens87%

Corn Hub's semantic search is O(1) — it returns ~137 tokens regardless of codebase size.


Troubleshooting

Error: Cannot find module '.../dist/cli.js'

  • Run pnpm build first — the dist/ folder is generated by the build step
  • Check the path points to YOUR local clone
  • On Windows, use forward slashes or escaped backslashes in JSON config

429 Too Many Requests from Voyage AI

  • Free tier: 3 RPM, 10K TPM. Corn Hub automatically retries with backoff and rotates models
  • Add a payment method at dashboard.voyageai.com for higher limits

Dashboard shows 0 agents / 0 queries

  • Restart your IDE to reload the MCP server with the latest telemetry interceptor
  • Ensure corn-api is running on port 4000

STDIO invalid character '\x1b' errors

  • Corn Hub patches console.log to redirect to stderr. If a dependency bypasses this, check for ANSI color output leaking to stdout.

Code intelligence returns empty results

  • Ensure your project is indexed: POST /api/intel/analyze {"projectId":"..."}
  • Check the project has gitRepoUrl set to a valid local directory path

Tech Stack

LayerTechnologyWhy
MCP ServerTypeScript + @modelcontextprotocol/sdkType-safe tool definitions
APIHono 4Ultra-fast, 0-dependency HTTP
Databasesql.js (WASM SQLite)In-memory + file persistence, no C++ deps
AST EngineTypeScript Compiler APIReal call graphs, not text grep
VectorsSQLite vector storeCosine similarity search, no external DB
EmbeddingsVoyage AI (voyage-code-3)Best-in-class code retrieval
DashboardNext.js 16 (Turbopack)Fast dev, modern React
Monorepopnpm + TurborepoIncremental builds

Releases

See the GitHub Releases page for version history and changelogs.


Contributors

yuki-20AntiTamper
🏆 Creator & Lead🤝 Co-Contributor

License

MIT © yuki-20

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "yuki-20-cornmcp": {
      "command": "",
      "args": []
    }
  }
}

将 CornMCP MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 CornMCP 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 CornMCP 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 CornMCP MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "yuki-20-cornmcp": {
      "command": "npx",
      "args": [
        "-y",
        "scalpel-mcp"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 CornMCP MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 CornMCP MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 CornMCP 帮我完成这项任务吗?
CornMCP
当然,我看过了。
以下是我使用 CornMCP 得到的结果。

常见问题

CornMCP MCP 服务器有什么用途?

CornMCP 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 CornMCP MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 CornMCP。

为什么在 TypingMind 中使用 CornMCP MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 CornMCP 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 CornMCP MCP 连接到 TypingMind?

CornMCP 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

CornMCP MCP 在 TypingMind 中提供哪些工具?

CornMCP 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 CornMCP MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 CornMCP 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇