Skip to content

add MCP server for runtime resource lookup#72

Closed
KhaiTrang1995 wants to merge 5 commits into
cobusgreyling:mainfrom
KhaiTrang1995:main
Closed

add MCP server for runtime resource lookup#72
KhaiTrang1995 wants to merge 5 commits into
cobusgreyling:mainfrom
KhaiTrang1995:main

Conversation

@KhaiTrang1995

Copy link
Copy Markdown
Contributor

Summary

Changes

MCP server exposes loop-engineering patterns, skills, state, budget,
and safety docs as queryable resources via Model Context Protocol.
Agents can query what they need on-demand instead of prompt stuffing.

Resources: registry, config, budget, run-log, safety, patterns/{id},
skills/{name}, state/{file}

Tools: list_patterns, list_skills, list_state_files, get_pattern,
get_skill, get_state, recommend_pattern, estimate_cost

Includes 16 tests, CI gate integration, and MCP config example.

Checklist (from CONTRIBUTING)

  • All required sections present for patterns
  • Links work from README, patterns/README, starters/README, docs/index
  • No secrets, tokens, internal company URLs
  • STATE.md* examples use .example suffix
  • Safety-related content references docs/safety.md
  • Ran node tools/loop-audit/dist/cli.js . (or on the starter) and addressed findings

Testing / Dogfood

  • loop-audit passes on affected starters or this repo
  • Manual review of generated state / skill output

Screenshots / Examples (if UI or command output)


This template enforces the high bar this reference is known for.

KhaiTrang1995 and others added 2 commits June 26, 2026 07:42
MCP server exposes loop-engineering patterns, skills, state, budget,
and safety docs as queryable resources via Model Context Protocol.
Agents can query what they need on-demand instead of prompt stuffing.

Resources: registry, config, budget, run-log, safety, patterns/{id},
skills/{name}, state/{file}

Tools: list_patterns, list_skills, list_state_files, get_pattern,
get_skill, get_state, recommend_pattern, estimate_cost

Includes 16 tests, CI gate integration, and MCP config example.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
feat(mcp-server): add MCP server for runtime resource lookup

@cobusgreyling cobusgreyling left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, CI passed. This is a large addition so I need a bit more time to review the MCP server code before approving. Will follow up soon.

@KhaiTrang1995

Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up! Take your time with the review.
By the way, I just noticed that zod hasn't been added to the dependencies yet. I'll push a quick fix for this right away.

KhaiTrang1995 and others added 3 commits June 26, 2026 16:41
…ation tests

zod was imported in src/index.ts but only resolved transitively via
@modelcontextprotocol/sdk, so the build could break if the SDK changed
its zod range. Declare it explicitly in dependencies.

Add 4 integration tests that spawn the real server over stdio and exercise
the index.ts tool/resource handlers (tools/list, loop_list_patterns,
loop_estimate_cost, pattern resource read), complementing the existing
resolver-level unit tests. Suite now 20/20 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(mcp-server): declare zod as direct dependency + add server ation tests

@cobusgreyling cobusgreyling left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strong contribution — MCP runtime lookup is exactly the right direction for reducing prompt stuffing. Not merge-ready yet; a few gaps to close first.

What's good:

  • zod is now in dependencies ✓ (fixes the issue you flagged)
  • Committed dist/ matches loop-audit / loop-init convention ✓
  • CI gate wired in scripts/ci-validate-gates.sh + root test:mcp-server
  • 16 tests + example config at examples/mcp/loop-engineering.mcp.json
  • Resource surface (registry, patterns, skills, state, budget, safety) is well-scoped

Required before merge:

  1. Path traversal guard on user-supplied IDsloadPatternDoc(root, patternId) does path.join(root, 'patterns', \${patternId}.md`)with no validation. ApatternIdlike../READMEcould escape. Add an allowlist check againstregistry.yamlids (you already load the registry) or reject any id containing/, \, or ..`.

  2. Same for get_skill / skill name args — validate against listSkills() results before reading.

  3. README / discoverability cross-links — add loop-mcp-server to:

    • root README.md Quick Links table
    • docs/primitives-matrix.md (MCP row — "reference server ships with this repo")
    • examples/README.md
  4. npm publish path — other tools ship as @cobusgreyling/loop-* on npm. Either:

    • add a release workflow for @cobusgreyling/loop-mcp-server, or
    • document clearly as "run from repo / npx github:" only for v1 (and say so in README)
  5. Complete the PR checklist — several boxes still unchecked in the description.

Nice-to-have (can follow in a fast follow PR):

  • recommend_pattern tool: document decision logic or add tests for each picker branch
  • estimate_cost tool: delegate to loop-cost logic or note it's approximate
  • Consider LOOP_PROJECT_ROOT validation (resolve + ensure expected markers like patterns/registry.yaml exist)

Rebase on latest main when ready — happy to re-review quickly once the path guards and README links land.

@cobusgreyling

Copy link
Copy Markdown
Owner

Thanks again for this — I rebased your branch onto latest main and pushed the path-guard + discoverability fixes to #87 (fix/pr-72-mcp-path-guards).

What landed on top of your work:

  • loadPatternDoc / loadState now allowlist IDs and reject .. / path separators
  • 2 regression tests in tools/mcp-server/test/server.test.mjs
  • README / primitives matrix / examples cross-links
  • Repo-only v1 install note (npm publish can follow)

If #87 merges, you'll get full credit in the merge commit. Happy to co-author or adjust anything — shout if you'd prefer to cherry-pick b1252e8 onto your branch instead.

cobusgreyling added a commit that referenced this pull request Jun 29, 2026
feat(mcp-server): runtime resource lookup + path guards (#72)
@cobusgreyling

Copy link
Copy Markdown
Owner

Superseded by #87 (merged) — path guards + docs included. Thanks @KhaiTrang1995!

pull Bot pushed a commit to Ricky-G/loop-engineering that referenced this pull request Jun 29, 2026
…reyling#72)

- Allowlist pattern IDs via registry / patterns dir listing
- Allowlist state files; reject .. / slashes in user-supplied segments
- Add regression tests for traversal attempts
- Cross-link from README, primitives matrix, examples README
- Document repo-only v1 install in mcp-server README

Builds on community PR cobusgreyling#72 by @KhaiTrang1995
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.

2 participants