Chicken Business Management MCP Server

Chicken Business Management MCP Server

Enables real-time voice-to-text order processing and chicken business management through WebSocket connections and REST APIs. Supports inventory tracking, sales parsing, stock forecasting, and note collection with AI-powered transcript correction and structured data extraction.

Category
访问服务器

README

mcp-server

Add to .env: JWT_SECRET=your_jwt_secret_here (generate a strong one, e.g., via openssl rand -hex 32)

Real-Time WebSockets

For live voice parsing (e.g., orders with inaccuracies), use WebSockets on port 3002.

Client Example (Browser with Web Speech API)

const ws = new WebSocket('ws://localhost:3002'); // Add ?token=your-jwt for auth
ws.onopen = () => console.log('Connected');
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = (event) => {
  for (let i = event.resultIndex; i < event.results.length; i++) {
    const chunk = event.results[i][0].transcript;
    ws.send(JSON.stringify({
      toolName: 'live_voice_stream',
      params: { streamId: 'session1', transcriptChunk: chunk, products: [{id: 'whole', name: 'Whole Chicken'}] }
    }));
  }
};
ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.partialParse) console.log('Partial:', data.partialParse); // e.g., {items: [{productId: 'whole', qty: 2}], confidence: 0.8}
  if (data.final) console.log('Final sales:', data.final); // Structured {items, payment}
  if (data.streamChunk) console.log('Gemini correction:', data.streamChunk);
};
recognition.start();

Server Protocol

  • Connect: ws://localhost:3002 (upgrade with Authorization: Bearer <jwt>)
  • Send: JSON {toolName: 'live_voice_stream', params: {streamId, transcriptChunk, products?}}
  • Receive: Streamed {partialParse: {...}, confidence: number} or {final: {structuredSales: {...}}, streamId}
  • Timeout: 5s for final parse; fuzzy + Gemini streaming handles "chikin" → "Whole Chicken".

Integrate with Todo 1 auth for secure streams.

Database Migrations

The server auto-migrates the DB on startup using service role (runs sql/enhanced-database-schema.sql if tables missing, idempotent check via notes table).

  • Auto: On npm run dev/start, migrate() called in constructor—logs to ai_audit_logs.
  • Manual: Build (npm run build), then node dist/migrate.js (standalone run, logs errors).
  • Schema: Edit sql/enhanced-database-schema.sql for changes (tables: notes, entities, relations, observations, ai_audit_logs, products, sales; pgvector indexes).
  • Fallback: If fails, manual Supabase SQL editor run schema.sql (service role bypasses RLS).

Scalability

For production scale, use cluster mode:

  • Run: npm run start:cluster (env WORKERS=4 for multi-core).
  • Guide: See [MD files/scalability.md](MD files/scalability.md) for multi-instance, concurrency opts (batch=5), load balancing (WS sticky).

API Integration Examples

Note Workflow (curl with JWT)

  1. Auth: curl -X POST http://localhost:3002/auth -H "Content-Type: application/json" -d '{"token":"your_mcp_auth_token"}' → {"token": "jwt_here"}

  2. Collect note: curl -X POST http://localhost:3002/api/tools/call -H "Authorization: Bearer jwt_here" -H "Content-Type: application/json" -d '{"name":"note_collection","arguments":{"content":"Bought 20 bags whole chicken for 10000 pesos","userRole":"owner"}}' → {"success":true,"result":{"note_id":"uuid","message":"Note collected"}}

  3. Parse: curl -X POST ... -d '{"name":"parse_chicken_note","arguments":{"note_id":"uuid"}}' → {"success":true,"result":{"parsed_data":{"purchases":[{"productId":"whole","qty":20,"cost":10000}],"status":"parsed"}}}

  4. Apply: curl -X POST ... -d '{"name":"apply_to_stock","arguments":{"note_id":"uuid"}}' → {"success":true,"message":"Stock updated"}

Deployment (Heroku/Codespace)

  • Heroku: heroku create, git push heroku main, heroku config:set GEMINI_API_KEY=... SUPABASE_URL=... JWT_SECRET=... WORKERS=4
  • Procfile: web: npm run start:cluster
  • Codespace: npm run dev:cluster (env WORKERS=2)
  • Scale: heroku ps:scale web=2 (multi-dyno load balance)

Troubleshooting

  • Proxy retries: AdvancedGeminiProxy backoff 3x on 429/5xx (check logs).
  • Rate limits: 10/min/user (Todo 1, 429 error); increase env MAX_REQUESTS_PER_MINUTE.
  • DB issues: Auto-migrate on start; manual node dist/migrate.js if fail (check ai_audit_logs).
  • WS auth: ws://localhost:3002?token=jwt_here for live_voice_stream.

Integration Examples

Note Workflow (curl with JWT)

  1. Auth: curl -X POST http://localhost:3002/auth -H "Content-Type: application/json" -d '{"token":"your_mcp_auth_token"}' (get JWT).

  2. Collect Note: curl -X POST http://localhost:3002/api/tools/call -H "Authorization: Bearer <jwt>" -H "Content-Type: application/json" -d '{"name":"note_collection","arguments":{"content":"Bought 20 bags whole chicken for ₱10k","userRole":"owner"}}' (response {note_id, success}).

  3. Parse: curl -X POST ... -d '{"name":"parse_chicken_note","arguments":{"note_id":"<id>"}}' (response {parsed: {purchases: [{productId:"whole", qty:20, cost:10000}]}}).

  4. Apply: curl -X POST ... -d '{"name":"apply_to_stock","arguments":{"note_id":"<id>","dry_run":false}}' (response {success, stockUpdated}).

Voice Stream (WS)

See Real-Time WebSockets section.

Forecast: curl -X POST ... -d '{"name":"forecast_stock","arguments":{"salesHistory":[{"date":"2025-09-22","amount":5000}]}}' (response {predictedSales: [{day:"1", amount:5500, confidence:0.8}], summary}).

Deployment

Heroku

  1. Procfile: web: npm start:cluster
  2. Env: GEMINI_API_KEY, SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, MCP_AUTH_TOKEN, JWT_SECRET, PORT=3002, WORKERS=2
  3. Deploy: git push heroku main; heroku scale web=2 (multi-dyno for scale).

Codespace

  1. .devcontainer/devcontainer.json: postCreateCommand "npm i && npm run build"
  2. Run: npm run dev:cluster (env WORKERS=4)

See scalability.md for multi-instance.

Troubleshooting

  • Proxy Retries: advanced-gemini-proxy.ts backoff on 429/5xx (env GEMINI_RETRY_MAX=3).
  • Rate Limits: 10/min/user (per Todo 1); 429 response—wait 60s.
  • DB Issues: Auto-migrate on start; manual node dist/migrate.js if fail (check Supabase logs).
  • Auth Errors: 401/403—verify JWT expiry (1h, refresh via /auth); MCP_AUTH_TOKEN in .env.
  • Tool Errors: 422 validation (check schemas in openapi.yaml); log ai_audit_logs for details.
  • WS Disconnect: Reconnect on close, pass token in query ?token=<jwt>.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选