Skip to content

chore: delete MCP runtime + enforce topology in CLI#92

Merged
KailasMahavarkar merged 5 commits intomainfrom
chore/delete-mcp-enforce-topology
Apr 22, 2026
Merged

chore: delete MCP runtime + enforce topology in CLI#92
KailasMahavarkar merged 5 commits intomainfrom
chore/delete-mcp-enforce-topology

Conversation

@KailasMahavarkar
Copy link
Copy Markdown
Collaborator

Summary

Removes the MCP server entrypoint and every file that only existed to serve the MCP transport, then wires the topology bundle allow/deny policy into the CLI tool dispatch path so policy is actually enforced at call time.

Commits

  1. Replace @modelcontextprotocol/sdk type imports with a local ToolServer shim across 95 plugin/tool/registry/bridge files. No behavior change - pure type indirection.
  2. Delete MCP runtime - src/index.ts, src/registry.ts, all 11 plugin index.ts aggregators, src/plugins/hyperstack/, src/internal/setup-hyperstack.ts, scripts/{setup,start-mcp,ensure-singleton}.ts, Dockerfile, .dockerignore. Drops @modelcontextprotocol/sdk dependency. Drops start, dev, docker:run, mcp:start, setup scripts from package.json. Bumps version to 2.0.0.
  3. Delete unreachable engine modules navigation.ts, injector.ts, resolver.ts, skill-enforcer.ts, plus policy.ts:getBundleByCapability - zero consumers after audit.
  4. Strip corpus-reader dead code from 12 plugin tool files. Each file had 40-80 lines of YAML corpus loading that fell through to in-file data because corpus/ was deleted in PR chore: annihilate corpus/ and tests/ #91. Net 1292 lines removed.
  5. Enforce topology on CLI tool invocations via new --agent <id> flag (or HYPERSTACK_AGENT env var). New getBundleForTool + assertToolAllowedForAgent helpers in policy.ts. CLI rewrites arg parsing so agent and json flags can appear in any order. Forbidden/unlisted bundle calls are rejected before the handler runs.

Behavior after merge

hyperstack tool designer_resolve_intent --json '{"product":"x"}' --agent frontend-builder
# [topology] agent=frontend-builder bundle=frontend.design tool=designer_resolve_intent
# ...tool output

hyperstack tool golang_get_practice --json '{...}' --agent frontend-builder
# Agent frontend-builder is forbidden from bundle backend.lang.go (tool golang_get_practice).

hyperstack tool designer_resolve_intent --json '{...}'   # no agent, permissive

No MCP path remains. Plugin snippets are untouched. bun run build / bun run compile:context / bun run skills:index / bun run generate:local-tools / bun run generate:topology all exit 0.

Test plan

  • bun run build - typecheck exit 0
  • bun run compile:context - regenerates bootstrap
  • bun run skills:index - regenerates skills index
  • bun run generate:local-tools - 76 tools registered (hyperstack_setup gone, as expected)
  • bun run generate:topology - topology bootstrap + allow/deny markdown regenerated clean
  • CLI tool/route/artifact smoke tests pass with expected outputs and with topology enforcement both permissive and strict

KailasMahavarkar and others added 5 commits April 22, 2026 11:01
…oolServer shim

Introduces src/shared/tool-types.ts with a minimal ToolServer/ToolHandler/ToolResult/Plugin type surface that matches the signatures the plugin tools use. Replaces every `import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"` across 95 plugin tool, plugin index, registry, and tool-bridge files with `import type { ToolServer } from "...shared/tool-types.js"`. Removes the two remaining value imports of McpServer in hyperstack/index.ts and hyperstack/tools/setup.ts.

This severs the MCP SDK from the runtime code paths without changing any observable behavior. The shim keeps server.tool/server.resource/server.prompt signatures compatible with existing plugin registration, and tool-bridge continues to capture the handler through the same `as unknown as ToolServer` pattern.

Prepares for the next commit which deletes the MCP server entrypoint, docker scripts, and the @modelcontextprotocol/sdk dependency entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… retire docker path

Removes every file that existed solely to run Hyperstack as an MCP server and replaces the installation flow with the plain CLI entrypoint.

Deleted:
- src/index.ts - MCP stdio server boot
- src/registry.ts - plugin aggregator used only by the MCP boot
- src/plugins/<plugin>/index.ts for all 11 plugins - the aggregator wrappers around individual tool files. The stable tool names keep working because scripts/generate-local-tool-registry.ts scans src/plugins/<plugin>/tools/*.ts directly for `server.tool("name", ...)` matches.
- src/plugins/hyperstack/ entirely - only hosted the hyperstack_setup tool which generated MCP config patches
- src/internal/setup-hyperstack.ts - MCP config detection + generation helper
- scripts/setup.ts - interactive MCP installer
- scripts/start-mcp.ts - MCP stdio server launcher
- scripts/ensure-singleton.ts - docker singleton guard
- Dockerfile and .dockerignore

package.json:
- removes @modelcontextprotocol/sdk dependency
- drops start, dev, docker:run, mcp:start, setup scripts
- bumps version to 2.0.0 and retitles description to reflect the topology-driven CLI surface
- bun install confirmed the SDK is no longer referenced anywhere

Verified:
- bun run build - typecheck exit 0
- bun run generate:local-tools - regenerates registry (76 tools; hyperstack_setup removed)
- bun run generate:topology - topology bootstrap + allow/deny markdown regenerated clean
- hyperstack tool designer_resolve_intent --json '{...}' returns the expected result
- hyperstack route --json '{...}' returns a routed agent with required artifacts

Topology CLI is now the sole runtime. Plugin tools stay stable through the generated local-tool-registry; the MCP transport is retired.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ver, skill-enforcer)

Audit showed these modules are not imported by cli.ts, the router, the artifact validator, the tool bridge, or any script. They remained from the earlier exploration phase.

Deleted:
- src/engine/navigation.ts (getBundle, listAgentRouting - zero consumers)
- src/engine/injector.ts (buildInjectionSlice - zero consumers)
- src/engine/resolver.ts (resolveCapabilityContext - zero consumers outside itself)
- src/engine/skill-enforcer.ts (assertSkillAllowedForAgent - zero consumers)

Trimmed:
- src/engine/policy.ts no longer exports getBundleByCapability; BundlePolicy import removed along with it. Only getAgent, getDomain, and getStrictestProofMode remain, all of which are consumed by the router.

Typecheck still exits 0. Router, artifact validator, and CLI tool path unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reverts the 12 corpus-aware tool handlers back to in-file-only dispatch after PR #91 deleted the corpus/ directory. Each file had a 40-80 line loadCorpusX loader that read YAML files from a corpus tree that no longer exists, caught the ENOENT, and fell through to the plugin data. Net effect was dead code that re-read and parsed the corpus tree on every cold call path.

Files simplified:
- src/plugins/echo/tools/get-recipe.ts
- src/plugins/rust/tools/get-practice.ts
- src/plugins/golang/tools/get-practice.ts
- src/plugins/react/tools/get-pattern.ts
- src/plugins/ui-ux/tools/get-principle.ts
- src/plugins/shadcn/tools/get-component.ts
- src/plugins/motion/tools/get-api.ts
- src/plugins/motion/tools/get-examples.ts
- src/plugins/reactflow/tools/get-api.ts
- src/plugins/designer/tools/get-page-template.ts
- src/plugins/design-tokens/tools/get-procedure.ts
- src/plugins/lenis/tools/get-pattern.ts

Each tool now: zod-typed args -> in-file data lookup -> render. No YAML, no fs reads, no cache, no corpus namespace.

Verified:
- bun run build - typecheck exit 0
- bin/hyperstack.mjs tool designer_resolve_intent --json '{"product":"test"}' returns the expected output
- bin/hyperstack.mjs tool design_tokens_get_procedure --json '{"step":2}' returns the step 2 procedure (confirming plugin data path still works for a tool that was most corpus-backed under the old layout)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…CK_AGENT

Wires the bundle allow/deny policy that topology already declares into the actual tool dispatch path. Tools can now be rejected before any handler runs when the caller is acting as an agent that is not permitted to touch their bundle.

Engine:
- src/engine/policy.ts adds getBundleForTool which resolves a tool name to a bundle by longest matching tool_prefixes entry and assertToolAllowedForAgent which rejects with a precise error when the bundle is forbidden, not allowed, or the tool is not mapped at all.

CLI (src/cli.ts):
- rewrites arg parsing with a small flag parser so `--agent <id>` and `--json '{...}'` can appear in any order after the positional command/tool
- accepts HYPERSTACK_AGENT env as fallback for the agent identity
- when an agent is supplied, the tool command runs getAgent + assertToolAllowedForAgent before invoking the tool; emits a single [topology] breadcrumb to stderr on success
- usage text documents the new enforcement behavior
- route and artifact validate paths unchanged

Behavior verified:
- `hyperstack tool designer_resolve_intent --json '{}'` (no agent) runs permissively (back-compat)
- `--agent frontend-builder` on a designer_ tool allows it and logs bundle=frontend.design
- `--agent frontend-builder` on a golang_ tool rejects with "forbidden from bundle backend.lang.go"
- `--agent backend-builder` on a golang_ tool allows it (bundle=backend.lang.go)
- `--agent ghost` errors with "Unknown agent: ghost"
- unmapped tool name errors with "not mapped to any bundle"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@KailasMahavarkar KailasMahavarkar merged commit b12b0e0 into main Apr 22, 2026
4 checks passed
@KailasMahavarkar KailasMahavarkar deleted the chore/delete-mcp-enforce-topology branch April 22, 2026 05:40
KailasMahavarkar added a commit that referenced this pull request Apr 22, 2026
Destructive reset of repo tree to 62f487e (feat: expand platform support to 12 IDEs/CLIs with format-aware patching) from 2026-04-15.

Wipes all work merged to main after 62f487e including PRs #63..#92: docker-primary fixes, topology manifest introduction, routing/artifact contracts, workspace-first routing, all corpus-backed slice PRs (#81..#90), corpus/tests removal (#91), MCP runtime deletion + topology enforcement (#92).

Tree equals 62f487e exactly. This is a destructive reset expressed as a single forward commit because branch protection on main forbids non-fast-forward push; the admin-merge path is used instead.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant