Skip to content

Conversation

@betterclever
Copy link
Contributor

Summary

Redis-backed registry for storing tool metadata and credentials during workflow runs. This bridges the gap between Temporal workflows (where credentials are resolved) and the MCP gateway (where agents call tools).

Stacked PR

This PR is stacked on top of #207 (ENG-95: Component SDK Tool Mode)

Please merge #207 first, then rebase this PR.

Changes

New: `backend/src/mcp/` module

ToolRegistryService:

  • `registerComponentTool()` - Register a ShipSec component as a tool with encrypted credentials
  • `registerRemoteMcp()` - Register a remote HTTP MCP server
  • `registerLocalMcp()` - Register a local stdio MCP (Docker container)
  • `getToolsForRun()` - Get all tools for a workflow run
  • `getTool()` / `getToolByName()` - Get specific tool
  • `getToolCredentials()` - Decrypt and return credentials
  • `areAllToolsReady()` - Check if all required tools are ready
  • `cleanupRun()` - Clean up tools and return container IDs

Redis Key Pattern

```
mcp:run:{runId}:tools (Hash, TTL 1hr)
```

Security

  • Credentials encrypted using existing `SecretsEncryptionService`

Tests

  • 8 tests covering all service methods

Note

Temporal activities (`registerToolActivity`, `waitForToolsActivity`, etc.) will be added in a follow-up as they reside in the worker package.

Linear Issue

Closes ENG-96

ENG-96

- Create ToolRegistryService with Redis-backed storage
- Implement registerComponentTool, registerRemoteMcp, registerLocalMcp
- Implement getToolsForRun, getTool, getToolByName, getToolCredentials
- Implement areAllToolsReady for agent readiness check
- Implement cleanupRun for workflow completion cleanup
- Encrypt credentials using existing SecretsEncryptionService
- Redis key pattern: mcp:run:{runId}:tools (Hash, TTL 1hr)
- Add McpModule to app imports
- Add comprehensive tests (8 tests passing)

Note: Temporal activities (registerToolActivity, waitForToolsActivity, etc.)
will be added in a follow-up as they reside in the worker package.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f8251468d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +292 to +295
try {
const encryptionMaterial = JSON.parse(tool.encryptedCredentials);
const decrypted = await this.encryption.decrypt(encryptionMaterial);
return JSON.parse(decrypted);

Choose a reason for hiding this comment

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

P2 Badge Handle non-JSON auth tokens in getToolCredentials

registerRemoteMcp encrypts a raw authToken string, but getToolCredentials always JSON.parses the decrypted payload. When the tool is a remote MCP (auth token is a plain string, not JSON), JSON.parse(decrypted) throws and the method returns null, so any consumer trying to fetch credentials for remote MCPs will never receive the token. This breaks authenticated remote MCP calls whenever authToken is not JSON-encoded.

Useful? React with 👍 / 👎.

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