Skip to content

Conversation

@Scra3
Copy link
Member

@Scra3 Scra3 commented Dec 13, 2025

Summary

  • Extract framework-agnostic McpHandlers class from Express-based MCP server
  • Agent now creates native Koa routes using the handlers instead of bridging Express middleware
  • Remove express-to-koa.ts utility (no longer needed)
  • Add getAuthorizationUrl() method to ForestOAuthProvider for framework-agnostic authorization

Architecture

The @forestadmin/mcp-server package now exports:

  • McpHandlers: Framework-agnostic class that returns data/results instead of manipulating response objects
  • ForestMCPServer: Express-based server (kept for CLI/standalone usage)

The agent creates native Koa routes that use McpHandlers:

// In agent.ts
const handlers = new McpHandlers(options);
await handlers.initialize();

router.get('/.well-known/oauth-authorization-server', ctx => {
  ctx.body = handlers.getOAuthMetadata(baseUrl);
});

router.post('/oauth/authorize', async ctx => {
  const result = await handlers.handleAuthorize(params);
  if (result.type === 'redirect') ctx.redirect(result.url);
});

Benefits

  • No Express-to-Koa bridging needed
  • Cleaner separation of concerns (handlers vs HTTP layer)
  • Framework-agnostic handlers can be reused with any HTTP framework
  • Native Koa integration in agent

Test plan

  • All unit tests pass (yarn test)
  • Build passes (yarn build)
  • Lint passes

🤖 Generated with Claude Code

alban bertolini and others added 4 commits December 11, 2025 12:02
Add new package for AI/LLM integration with MCP server support.

- Router for handling AI proxy requests with provider configuration
- MCP client for connecting to Model Context Protocol servers
- Remote tools abstraction for external tool invocations
- Provider dispatcher for multi-provider LLM support
- Comprehensive test coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add service to fetch MCP server configurations from Forest Admin API.

- New McpServerConfigService for fetching MCP server configs
- Add getMcpServerConfigs endpoint to ForestHttpApi
- Integrate service into ForestAdminClient

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add support for AI/LLM integration in the agent package.

- New addAI customization method for configuring AI provider
- AI proxy route handler at /_internal/ai-proxy/:route
- Integration with MCP server configuration service
- Schema flag for AI enabled projects

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This refactor introduces McpHandlers class that provides framework-agnostic
handlers for MCP OAuth and protocol requests. This allows:

1. MCP logic to be reused with any HTTP framework (Express, Koa, etc.)
2. Agent to use native Koa routes instead of Express-to-Koa bridging
3. Cleaner separation between protocol logic and HTTP framework

Key changes:
- Add McpHandlers class with framework-agnostic methods:
  - getOAuthMetadata(): returns OAuth metadata
  - getProtectedResourceMetadata(): returns protected resource metadata
  - handleAuthorize(): returns redirect URL or error
  - handleToken(): returns tokens or error
  - handleMcpRequest(): handles MCP protocol requests
- Add getAuthorizationUrl() to ForestOAuthProvider (returns URL string)
- Update agent to create native Koa routes using McpHandlers
- Update FrameworkMounter to mount Koa router for MCP routes
- Remove express-to-koa wrapper (no longer needed)
- Simplify useMcp() API (no factory needed)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@qltysh
Copy link

qltysh bot commented Dec 13, 2025

14 new issues

Tool Category Rule Count
qlty Structure Function with high complexity (count = 19): useCallbackOnFastify 5
qlty Structure Function with many returns (count = 4): handleAuthorize 4
qlty Structure Function with many parameters (count = 4): exchangeAuthorizationCode 3
qlty Structure Deeply nested control flow (level = 4) 2

@Scra3 Scra3 force-pushed the feat/add-ai-integration branch from 9dd379a to e5305ef Compare December 15, 2025 12:58
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