Skip to content

Add MCP site targeting (#72)#111

Merged
JohnONolan merged 1 commit into
mainfrom
codex/mcp-site-targeting
May 8, 2026
Merged

Add MCP site targeting (#72)#111
JohnONolan merged 1 commit into
mainfrom
codex/mcp-site-targeting

Conversation

@JohnONolan
Copy link
Copy Markdown
Member

Summary

  • add an optional per-call site argument to MCP tools so one server can target multiple configured Ghost sites
  • add ghost_site_list for credential-safe alias discovery
  • document the multi-instance MCP workflow and cover routing/schema behavior in tests

Why

A single MCP server should be able to operate across configured Ghost instances without requiring one MCP process per site. The site argument acts as a routing selector only: it is validated with the existing site alias schema, applied to connection resolution, and stripped before downstream Ghost API calls.

Closes #72

Validation

  • pnpm vitest run tests/mcp-core-tools.test.ts tests/mcp-http-integration.test.ts
  • pnpm lint && pnpm typecheck && pnpm test && pnpm build

Note: pnpm lint exits successfully but still reports existing Biome optional-chain warnings outside this change.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 649d1863-2795-463c-a3a9-6a7e51c106d1

📥 Commits

Reviewing files that changed from the base of the PR and between b64ac60 and 710c95d.

📒 Files selected for processing (5)
  • AGENTS.md
  • README.md
  • src/mcp/tools/core.ts
  • tests/mcp-core-tools.test.ts
  • tests/mcp-http-integration.test.ts
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/mcp-core-tools.test.ts

Walkthrough

This PR introduces multi-instance support to the MCP server by adding an optional site argument to all MCP tools, enabling per-call targeting of configured Ghost site aliases. A new ghost_site_list tool safely discovers configured sites without exposing credentials. The implementation refactors tool registration from individual server.registerTool() calls to a unified site-aware helper that injects the site schema and scopes global options. Tests verify per-call routing to correct hostnames, backward compatibility when site is omitted, and that site values do not leak into Ghost request parameters or bodies.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add MCP site targeting (#72)' clearly and concisely describes the main change: adding site-targeting capability to MCP tools, with issue reference.
Description check ✅ Passed The description comprehensively explains the changes, motivation, and validation approach, directly addressing the multi-instance MCP workflow objective.
Linked Issues check ✅ Passed Code changes fully implement the requirements from issue #72: optional per-call site argument routing to different Ghost instances, credential-safe site discovery via ghost_site_list, and multi-instance workflow support.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing multi-instance MCP support: documentation updates, core tool registration refactoring, and comprehensive test coverage align with the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/mcp-site-targeting

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/mcp/tools/core.ts (1)

1326-1334: 💤 Low value

Minor: Handler signature inconsistent with similar tools.

The handler ignores parameters, but for consistency with other no-argument tools like ghost_site_info (line 1323), consider matching the pattern:

-      async () => toolResult(await listConfiguredSites()),
+      async (_global) => toolResult(await listConfiguredSites()),

This clarifies that the tool intentionally doesn't use the global context (since it reads from local config rather than making API calls).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/mcp/tools/core.ts` around lines 1326 - 1334, The handler for the
ghost_site_list tool currently ignores parameters; change its signature to
explicitly accept the same parameters used by similar no-argument tools (e.g.,
accept the global/context param) so it matches the pattern of ghost_site_info;
update the anonymous async handler passed to registerGhostTool (referencing
registerGhostTool, toolResult, and listConfiguredSites) to take the global
argument (even if unused) and then call toolResult(await listConfiguredSites())
to make the unused global explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/mcp/tools/core.ts`:
- Around line 1326-1334: The handler for the ghost_site_list tool currently
ignores parameters; change its signature to explicitly accept the same
parameters used by similar no-argument tools (e.g., accept the global/context
param) so it matches the pattern of ghost_site_info; update the anonymous async
handler passed to registerGhostTool (referencing registerGhostTool, toolResult,
and listConfiguredSites) to take the global argument (even if unused) and then
call toolResult(await listConfiguredSites()) to make the unused global explicit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47e6b6a1-4336-4fb5-92da-ad2150287e76

📥 Commits

Reviewing files that changed from the base of the PR and between e3b9608 and b64ac60.

📒 Files selected for processing (5)
  • AGENTS.md
  • README.md
  • src/mcp/tools/core.ts
  • tests/mcp-core-tools.test.ts
  • tests/mcp-http-integration.test.ts

MCP tools need to operate across multiple configured Ghost sites without requiring one server process per site. This adds a shared MCP tool wrapper that accepts an optional site alias, validates it, scopes connection resolution per call, and strips the routing argument before downstream Ghost API calls.

Adds ghost_site_list for credential-safe site discovery and covers per-call routing, omitted arguments, schema visibility, and credential omission in tests.

Closes #72
@JohnONolan JohnONolan force-pushed the codex/mcp-site-targeting branch from b64ac60 to 710c95d Compare May 8, 2026 18:40
@JohnONolan JohnONolan merged commit 3233596 into main May 8, 2026
4 checks passed
@JohnONolan JohnONolan deleted the codex/mcp-site-targeting branch May 8, 2026 18:51
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.

Multi-instance support for ghst mcp

1 participant