harness-mcp
harness-mcp
Шаблон на TypeScript с собственным подходом к созданию MCP-серверов, ориентированный на harness engineering.
Harness engineering — это дисциплина проектирования каркаса вокруг LLM-агента (инструменты, описания, ошибки, контекст), чтобы агент действительно выполнял нужные действия. Большинство шаблонов MCP обучают вас протоколу. Этот шаблон обучает вас и протоколу, и практике.
Что внутри
defineTool()— одна схема Zod обеспечивает работу SDK MCP, API вызова функций OpenAI и обработчика времени выполнения. Валидация и обертывание ошибок происходят автоматически.Оба транспорта — stdio (
src/index.ts) для локальных клиентов в стиле Claude Code, потоковый HTTP (src/http.ts) для удаленных/веб-клиентов. Оба используют одинcreateServer().Структурированные
AgentError— каждая ошибка имеетcode,messageиhint, написанные для модели: "сначала вызовитеitems_list, чтобы найти валидный id". Расплывчатые ошибки тратят попытки впустую; это решение исправляет проблему на уровне типов.Настоящий инструмент оценки (eval harness) — на базе Vitest. Модульные тесты запускаются в CI;
tests/mcp/echo.test.tsуправляет реальной моделью OpenAI через MCP-сервер с помощью пары транспортных соединений в памяти и проверяет итоговую трассировку вызовов инструментов.Простой пример CRUD —
items_create / list / read / update / deleteплюс инструментecho. Замените хранилище в памяти на ваш реальный бэкенд, сохранив структуру.
Related MCP server: TypeScript MCP Server Boilerplate
Быстрый старт
bun install
bun test # unit tests, no API key needed
bun run start # stdio server on stdin/stdout
bun run start:http # HTTP server on http://localhost:3000/mcpЧтобы запустить оценки с участием модели:
cp .env.example .env
# add OPENAI_API_KEY
bun run test:mcpПодключение к Claude Code
{
"mcpServers": {
"harness-mcp": {
"command": "bun",
"args": ["run", "/absolute/path/to/harness/mcp/src/index.ts"]
}
}
}Структура
src/
index.ts stdio entry
http.ts streamable-http entry
core/
server.ts createServer() — shared by both transports
tool.ts defineTool() wrapper
errors.ts AgentError
store.ts replace with your backend
tools/
echo.ts smoke-test tool
items-*.ts CRUD example tools
index.ts registry
tests/
unit/ fast, no API key
tool.test.ts
store.test.ts
mcp/ protocol + model-in-the-loop
setup.ts in-memory client + runWithModel() helper
smoke.test.ts no model
echo.test.ts gpt-4o-mini, skipped without OPENAI_API_KEYПринципы
Описания инструментов — это промпт-инжиниринг. Каждое описание начинается с
USE WHEN ...и включаетDO NOT USE WHEN ...для похожих инструментов, с которыми модель может их перепутать. Дымовое тестирование обеспечивает соблюдение этого правила.Ошибки обучают. Каждый
AgentErrorсодержит полеhint. Читайте свои сообщения об ошибках так, будто вы — агент: поняли бы вы, что делать дальше? Если нет, перепишите их.Эндпоинты списка используют пагинацию.
items_listвозвращает{ items, nextCursor }. Лимит по умолчанию 20, жесткий лимит 100. Не выгружайте неограниченные данные в контекст.Деструктивные операции поддерживают
dryRun.items_deleteсообщит вам, что произошло бы, если вы не уверены в действии.Один Zod, три потребителя. Не поддерживайте JSON Schema вручную параллельно с Zod —
defineToolвыводит оба варианта.Оценки — это тесты. Трассировки вызовов инструментов можно проверять утверждениями (assert). Когда регрессия в описании нарушает поведение модели, ваш тест это обнаружит.
Лицензия
MIT.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA TypeScript-based template for rapidly developing MCP servers with modular tool architecture, built-in validation using Zod schemas, and comprehensive error handling.9MIT
- FlicenseAqualityDmaintenanceA boilerplate for building MCP servers using TypeScript, with example tools like calculator and greet, plus resource support.6
- FlicenseBqualityCmaintenanceA TypeScript MCP server boilerplate providing example tools and resources for rapid development of custom Model Context Protocol servers.8
- FlicenseNot gradedqualityDmaintenanceA TypeScript MCP server boilerplate providing example tools and resources for rapid development and testing of Model Context Protocol servers.
Related MCP Connectors
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
A MCP server built for developers enabling Git based project management with project and personal…
Kickstart development with a customizable TypeScript template featuring sample tools for greeting,…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/giuseppecrj/harness-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server