Skip to content

Commit de5f12c

Browse files
Create new agents-mcp package (#1588)
* new agents-mcp package and removal from biome * checkpoint * add gh ci action * chore: add changeset for new @inkeep/agents-mcp package * fix(ci): add @inkeep/agents-mcp to E2E test build step The agents-api package depends on @inkeep/agents-mcp, so it needs to be built before running the integration tests in CI. * Apply suggestions from code review Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> * Fix turbo command not found in CI Use pnpm turbo instead of bare turbo command since turbo is a devDependency, not globally installed. --------- Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
1 parent ecceef2 commit de5f12c

File tree

836 files changed

+81657
-17504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

836 files changed

+81657
-17504
lines changed

.changeset/unified-mcp-server.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@inkeep/agents-mcp": minor
3+
---
4+
5+
Add new `@inkeep/agents-mcp` package providing a unified MCP server for AI assistants to interact with the Inkeep Agents platform. This package combines all APIs (manage, run, evals) into a single MCP server, exposing tools for managing agents, projects, tools, credentials, evaluations, datasets, and workflows.

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ jobs:
200200
run: |
201201
# Build all packages that the e2e test links to local versions
202202
# These need dist/ directories for subpath exports like ./factory
203-
pnpm --filter @inkeep/agents-core build
203+
pnpm turbo run build --filter=@inkeep/create-agents
204204
pnpm --filter @inkeep/agents-manage-mcp build
205+
pnpm --filter @inkeep/agents-mcp build
205206
pnpm --filter @inkeep/agents-sdk build
206207
pnpm --filter @inkeep/agents-api build
207208
pnpm --filter @inkeep/agents-cli build
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Speakeasy SDK Generation
2+
3+
on:
4+
workflow_dispatch: {} # Manual trigger
5+
schedule:
6+
- cron: '0 0 * * *' # Daily at midnight UTC
7+
8+
jobs:
9+
generate:
10+
name: Generate agents-mcp SDK
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Generate SDK
16+
uses: speakeasy-api/sdk-generation-action@v15
17+
with:
18+
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
19+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
20+
mode: pr
21+
working_directory: packages/agents-mcp

agents-api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@hono/zod-openapi": "^1.1.5",
6060
"@inkeep/agents-core": "workspace:^",
6161
"@inkeep/agents-manage-mcp": "workspace:^",
62+
"@inkeep/agents-mcp": "workspace:^",
6263
"@modelcontextprotocol/sdk": "^1.25.2",
6364
"@openrouter/ai-sdk-provider": "^1.2.0",
6465
"@opentelemetry/api": "^1.9.0",

agents-api/src/createApp.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { evalRoutes } from './domains/evals';
77
import { workflowRoutes } from './domains/evals/workflow/routes';
88
import { githubRoutes } from './domains/github';
99
import { manageRoutes } from './domains/manage';
10+
import mcpRoutes from './domains/mcp/routes/mcp';
1011
import { runRoutes } from './domains/run';
1112
import { env } from './env';
1213
import { flushBatchProcessor } from './instrumentation';
@@ -365,6 +366,10 @@ function createAgentsHono(config: AppConfig) {
365366
// Mount GitHub routes - unauthenticated, OIDC token is the authentication
366367
app.route('/api/github', githubRoutes);
367368

369+
// Mount MCP routes at top level (eclipses both manage and run services)
370+
// Also available at /manage/mcp for backward compatibility
371+
app.route('/mcp', mcpRoutes);
372+
368373
// Setup OpenAPI documentation endpoints (/openapi.json and /docs)
369374
setupOpenAPIRoutes(app);
370375

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { StreamableHTTPTransport } from '@hono/mcp';
2+
import {
3+
createConsoleLogger,
4+
createMCPServer,
5+
HeaderForwardingHook,
6+
InkeepAgentsCore,
7+
SDKHooks,
8+
} from '@inkeep/agents-mcp';
9+
import { Hono } from 'hono';
10+
import { env } from '../../../env';
11+
12+
const app = new Hono();
13+
14+
/**
15+
* Headers to forward from incoming requests to downstream API calls.
16+
* x-forwarded-cookie is mapped to cookie for browser compatibility
17+
* (browsers don't allow setting Cookie header directly).
18+
*/
19+
const FORWARDED_HEADERS = ['x-forwarded-cookie', 'authorization', 'cookie'] as const;
20+
21+
app.all('/', async (c) => {
22+
const transport = new StreamableHTTPTransport();
23+
const noOpLogger = createConsoleLogger('error');
24+
25+
const headersToForward: Record<string, string> = {};
26+
for (const headerName of FORWARDED_HEADERS) {
27+
const value = c.req.header(headerName);
28+
if (value) {
29+
headersToForward[headerName] = value;
30+
}
31+
}
32+
33+
if (headersToForward['x-forwarded-cookie'] && !headersToForward.cookie) {
34+
headersToForward.cookie = headersToForward['x-forwarded-cookie'];
35+
}
36+
37+
const createSDKWithHeaders = () => {
38+
const hooks = new SDKHooks();
39+
hooks.registerBeforeRequestHook(new HeaderForwardingHook(headersToForward));
40+
41+
return new InkeepAgentsCore({
42+
serverURL: env.INKEEP_AGENTS_API_URL,
43+
hooks,
44+
} as any);
45+
};
46+
47+
const mcpServer = createMCPServer({
48+
logger: noOpLogger,
49+
serverURL: env.INKEEP_AGENTS_API_URL,
50+
getSDK: createSDKWithHeaders,
51+
});
52+
53+
await mcpServer.server.connect(transport);
54+
return transport.handleRequest(c);
55+
});
56+
57+
export default app;

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"files": {
2121
"ignoreUnknown": false,
22-
"includes": ["**", "!packages/agents-manage-mcp"]
22+
"includes": ["**", "!packages/agents-manage-mcp", "!packages/agents-mcp"]
2323
},
2424
"linter": {
2525
"enabled": true,

packages/agents-mcp/.dxtignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.speakeasy
2+
.vscode
3+
bun.lock
4+
eslint.config.mjs
5+
node_modules

packages/agents-mcp/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This allows generated code to be indexed correctly
2+
*.ts linguist-generated=false

packages/agents-mcp/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**/.speakeasy/logs/
2+
**/.speakeasy/reports/
3+
**/.speakeasy/temp/
4+
/.eslintcache
5+
/.tsbuildinfo
6+
/bin
7+
/esm
8+
/node_modules
9+
bun.lock
10+
.DS_Store
11+
.env
12+
.env.local
13+
*.mcpb

0 commit comments

Comments
 (0)