feat: --agent-role / --agent-scope для domain-custom ролей#13
Merged
Conversation
До этого PR mcp-server подключался к host runtime'у с anonymous register —
host fallback'ился на DEFAULT_ROLE='agent'. Это работало для booking/
invest/freelance (где такая роль есть в ontology), но падало с 400
role_unknown для доменов с custom-ролями (e.g. infra с staging-agent/
infra-operator), а scope-фильтрация (Gate 4 Fold-демо) была недоступна
вовсе.
Изменения
bin/mcp-idf.js
--agent-role=<name> IDF_AGENT_ROLE
--agent-scope=<json> IDF_AGENT_SCOPE='{"environment":"staging"}'
src/auth.js — agentLogin принимает opts:{role,scope}, пробрасывает в
POST /api/auth/register body.opts. Login (existing user) — без opts,
metadata подгружается из БД.
src/server.js — createIdfMcpServer принимает agentRole/agentScope,
собирает opts и пробрасывает в agentLogin.
Live e2e verification (manual stdio harness против host runtime'а)
staging-agent с scope={environment:'staging'}:
→ tools/list: 4 (deleteResource, restartResource, scaleResource, viewResource)
→ resources/read[resources]: 3 rows, environments=['staging']
→ production resources ОТСУТСТВУЮТ
infra-operator (без scope):
→ tools/list: 6 (включая auto-injected approve_request/reject_request)
→ resources/read[resources]: 6 rows, environments=['staging','production']
Это закрывает Gate 4 Fold-демо через MCP (не только REST). Akt 2 видео
(«staging-agent через Claude Desktop не видит production») теперь
реально работает end-to-end через stdio-протокол.
Examples
mcp-idf --domain=infra \
--agent-role=staging-agent \
--agent-scope='{"environment":"staging"}'
IDF_AGENT_ROLE=infra-operator mcp-idf --domain=infra
# Booking/invest продолжают работать без opts (fallback 'agent' роль
# есть в этих ontology'ях):
mcp-idf --domain=booking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Зачем
Live e2e verification обнаружила: MCP server не работал с infra-доменом. До этого PR mcp-server подключался к host runtime'у с anonymous register — host fallback'ился на
DEFAULT_ROLE='agent'. Это работало для booking/invest/freelance (где такая роль есть в ontology), но падало с 400role_unknownдля доменов с custom-ролями (e.g. infra с staging-agent/infra-operator), а scope-фильтрация (Gate 4 Fold-демо) была недоступна вовсе.Без этого фикса pitch Fold'а «attack on what you don't see is impossible» через MCP не работал в принципе. Юнит-тесты mcp-server-а пропустили это — они не запускали реальный stdio flow с infra-доменом.
API
Live verification
End-to-end через JSON-RPC stdio harness. Akt 2 Fold-демо («staging-agent через Claude Desktop / Cursor / Zed не видит production») теперь реально работает.
Backward-compat
Существующие домены (booking/invest/freelance/...) продолжают работать без opts — host fallback'ится на
DEFAULT_ROLE='agent'если эта роль объявлена в ontology. Login для existing user'а не пробрасывает opts — metadata уже в БД.Связанные