agent-orchestrator-mcp-server 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/package.json +1 -1
- package/shared/cache/configs-cache.d.ts +27 -0
- package/shared/cache/configs-cache.js +33 -0
- package/shared/index.d.ts +1 -1
- package/shared/index.js +1 -1
- package/shared/orchestrator-client/orchestrator-client.d.ts +5 -1
- package/shared/orchestrator-client/orchestrator-client.integration-mock.js +52 -0
- package/shared/orchestrator-client/orchestrator-client.js +9 -0
- package/shared/resources.d.ts +8 -1
- package/shared/resources.js +140 -58
- package/shared/server.js +3 -2
- package/shared/tools/get-configs.d.ts +37 -0
- package/shared/tools/get-configs.js +154 -0
- package/shared/tools/start-session.d.ts +2 -2
- package/shared/tools/start-session.js +2 -0
- package/shared/tools.js +4 -1
- package/shared/types.d.ts +28 -0
package/README.md
CHANGED
|
@@ -7,9 +7,10 @@ MCP server for PulseMCP's agent-orchestrator: a Claude Code + MCP-powered agent-
|
|
|
7
7
|
|
|
8
8
|
## Highlights
|
|
9
9
|
|
|
10
|
-
- Simplified
|
|
10
|
+
- Simplified 5-tool interface for full agent session management
|
|
11
11
|
- Search, filter, and retrieve sessions with optional logs and transcripts
|
|
12
12
|
- Session lifecycle actions (pause, restart, archive, unarchive, follow_up, change_mcp_servers)
|
|
13
|
+
- Static configuration access via tools and MCP resources
|
|
13
14
|
- Tool grouping system for permission-based access control
|
|
14
15
|
- TypeScript with strict type checking
|
|
15
16
|
- Comprehensive testing setup (functional, integration, manual)
|
|
@@ -22,14 +23,18 @@ MCP server for PulseMCP's agent-orchestrator: a Claude Code + MCP-powered agent-
|
|
|
22
23
|
| ----------------- | -------- | ---------------------------------------------------------------------------------- |
|
|
23
24
|
| `search_sessions` | readonly | Search/list sessions with optional ID lookup, query, and status filter |
|
|
24
25
|
| `get_session` | readonly | Get detailed session info with optional logs and transcripts |
|
|
26
|
+
| `get_configs` | readonly | Fetch all static configuration (MCP servers, agent roots, stop conditions) |
|
|
25
27
|
| `start_session` | write | Create and start a new agent session |
|
|
26
28
|
| `action_session` | write | Perform actions: follow_up, pause, restart, archive, unarchive, change_mcp_servers |
|
|
27
29
|
|
|
28
30
|
### Resources
|
|
29
31
|
|
|
30
|
-
| Resource
|
|
31
|
-
|
|
|
32
|
-
| `agent-orchestrator://config`
|
|
32
|
+
| Resource | Description |
|
|
33
|
+
| ---------------------------------------------- | ----------------------------------------------- |
|
|
34
|
+
| `agent-orchestrator://config` | Server configuration and status (for debugging) |
|
|
35
|
+
| `agent-orchestrator://configs/mcp-servers` | List of available MCP servers for sessions |
|
|
36
|
+
| `agent-orchestrator://configs/agent-roots` | Preconfigured repository settings with defaults |
|
|
37
|
+
| `agent-orchestrator://configs/stop-conditions` | Session completion criteria definitions |
|
|
33
38
|
|
|
34
39
|
### Tool Groups
|
|
35
40
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cache for unified configs response.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized cache for the configs response
|
|
5
|
+
* that is shared between get_configs and get_available_mcp_servers tools.
|
|
6
|
+
*
|
|
7
|
+
* Cache behavior:
|
|
8
|
+
* - Session-level caching (persists for the lifetime of the MCP server process)
|
|
9
|
+
* - No TTL (time-to-live) - data is considered valid until force_refresh
|
|
10
|
+
* - Force refresh available via tool parameter
|
|
11
|
+
*/
|
|
12
|
+
import type { ConfigsResponse } from '../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Clear the configs cache.
|
|
15
|
+
* Useful for testing and for manual cache invalidation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function clearConfigsCache(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get the current configs cache state.
|
|
20
|
+
* Returns null if no data is cached.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getConfigsCache(): ConfigsResponse | null;
|
|
23
|
+
/**
|
|
24
|
+
* Update the configs cache with new data.
|
|
25
|
+
*/
|
|
26
|
+
export declare function setConfigsCache(configs: ConfigsResponse): void;
|
|
27
|
+
//# sourceMappingURL=configs-cache.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cache for unified configs response.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a centralized cache for the configs response
|
|
5
|
+
* that is shared between get_configs and get_available_mcp_servers tools.
|
|
6
|
+
*
|
|
7
|
+
* Cache behavior:
|
|
8
|
+
* - Session-level caching (persists for the lifetime of the MCP server process)
|
|
9
|
+
* - No TTL (time-to-live) - data is considered valid until force_refresh
|
|
10
|
+
* - Force refresh available via tool parameter
|
|
11
|
+
*/
|
|
12
|
+
// Module-level cache for configs (shared between tools)
|
|
13
|
+
let configsCache = null;
|
|
14
|
+
/**
|
|
15
|
+
* Clear the configs cache.
|
|
16
|
+
* Useful for testing and for manual cache invalidation.
|
|
17
|
+
*/
|
|
18
|
+
export function clearConfigsCache() {
|
|
19
|
+
configsCache = null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the current configs cache state.
|
|
23
|
+
* Returns null if no data is cached.
|
|
24
|
+
*/
|
|
25
|
+
export function getConfigsCache() {
|
|
26
|
+
return configsCache;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Update the configs cache with new data.
|
|
30
|
+
*/
|
|
31
|
+
export function setConfigsCache(configs) {
|
|
32
|
+
configsCache = configs;
|
|
33
|
+
}
|
package/shared/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createRegisterResources } from './resources.js';
|
|
2
2
|
export { registerTools, createRegisterTools, type ToolGroup, parseEnabledToolGroups, } from './tools.js';
|
|
3
3
|
export { createMCPServer, type ClientFactory, type IAgentOrchestratorClient } from './server.js';
|
|
4
4
|
export { AgentOrchestratorClient, type IAgentOrchestratorClient as AgentOrchestratorClientInterface, } from './orchestrator-client/orchestrator-client.js';
|
package/shared/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Core server exports
|
|
2
|
-
export {
|
|
2
|
+
export { createRegisterResources } from './resources.js';
|
|
3
3
|
export { registerTools, createRegisterTools, parseEnabledToolGroups, } from './tools.js';
|
|
4
4
|
export { createMCPServer } from './server.js';
|
|
5
5
|
// Client exports
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A client for interacting with the Agent Orchestrator REST API.
|
|
5
5
|
*/
|
|
6
|
-
import type { Session, Log, SubagentTranscript, SessionsResponse, SearchSessionsResponse, SessionActionResponse, LogsResponse, SubagentTranscriptsResponse, CreateSessionRequest, UpdateSessionRequest, CreateLogRequest, UpdateLogRequest, CreateSubagentTranscriptRequest, UpdateSubagentTranscriptRequest, SessionStatus, LogLevel, SubagentStatus } from '../types.js';
|
|
6
|
+
import type { Session, Log, SubagentTranscript, SessionsResponse, SearchSessionsResponse, SessionActionResponse, LogsResponse, SubagentTranscriptsResponse, CreateSessionRequest, UpdateSessionRequest, CreateLogRequest, UpdateLogRequest, CreateSubagentTranscriptRequest, UpdateSubagentTranscriptRequest, SessionStatus, LogLevel, SubagentStatus, MCPServerInfo, ConfigsResponse } from '../types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Interface for the Agent Orchestrator API client.
|
|
9
9
|
* Used for dependency injection and testing.
|
|
@@ -53,6 +53,8 @@ export interface IAgentOrchestratorClient {
|
|
|
53
53
|
createSubagentTranscript(sessionId: string | number, data: CreateSubagentTranscriptRequest): Promise<SubagentTranscript>;
|
|
54
54
|
updateSubagentTranscript(sessionId: string | number, transcriptId: number, data: UpdateSubagentTranscriptRequest): Promise<SubagentTranscript>;
|
|
55
55
|
deleteSubagentTranscript(sessionId: string | number, transcriptId: number): Promise<void>;
|
|
56
|
+
getMcpServers(): Promise<MCPServerInfo[]>;
|
|
57
|
+
getConfigs(): Promise<ConfigsResponse>;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Implementation of the Agent Orchestrator API client.
|
|
@@ -107,5 +109,7 @@ export declare class AgentOrchestratorClient implements IAgentOrchestratorClient
|
|
|
107
109
|
createSubagentTranscript(sessionId: string | number, data: CreateSubagentTranscriptRequest): Promise<SubagentTranscript>;
|
|
108
110
|
updateSubagentTranscript(sessionId: string | number, transcriptId: number, data: UpdateSubagentTranscriptRequest): Promise<SubagentTranscript>;
|
|
109
111
|
deleteSubagentTranscript(sessionId: string | number, transcriptId: number): Promise<void>;
|
|
112
|
+
getMcpServers(): Promise<MCPServerInfo[]>;
|
|
113
|
+
getConfigs(): Promise<ConfigsResponse>;
|
|
110
114
|
}
|
|
111
115
|
//# sourceMappingURL=orchestrator-client.d.ts.map
|
|
@@ -380,5 +380,57 @@ export function createIntegrationMockOrchestratorClient(initialMockData) {
|
|
|
380
380
|
}
|
|
381
381
|
mockData.subagentTranscripts?.splice(index, 1);
|
|
382
382
|
},
|
|
383
|
+
async getMcpServers() {
|
|
384
|
+
return [
|
|
385
|
+
{
|
|
386
|
+
name: 'github-development',
|
|
387
|
+
title: 'GitHub Development',
|
|
388
|
+
description: 'Interact with GitHub repositories, issues, and pull requests',
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: 'slack',
|
|
392
|
+
title: 'Slack',
|
|
393
|
+
description: 'Send and receive messages in Slack workspaces',
|
|
394
|
+
},
|
|
395
|
+
];
|
|
396
|
+
},
|
|
397
|
+
async getConfigs() {
|
|
398
|
+
return {
|
|
399
|
+
mcp_servers: [
|
|
400
|
+
{
|
|
401
|
+
name: 'github-development',
|
|
402
|
+
title: 'GitHub Development',
|
|
403
|
+
description: 'Interact with GitHub repositories, issues, and pull requests',
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
name: 'slack',
|
|
407
|
+
title: 'Slack',
|
|
408
|
+
description: 'Send and receive messages in Slack workspaces',
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
agent_roots: [
|
|
412
|
+
{
|
|
413
|
+
name: 'mcp-servers',
|
|
414
|
+
title: 'MCP Servers',
|
|
415
|
+
description: 'PulseMCP MCP servers monorepo',
|
|
416
|
+
git_root: 'https://github.com/pulsemcp/mcp-servers.git',
|
|
417
|
+
default_branch: 'main',
|
|
418
|
+
default_mcp_servers: ['github-development'],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
stop_conditions: [
|
|
422
|
+
{
|
|
423
|
+
id: 'pr_merged',
|
|
424
|
+
name: 'PR Merged',
|
|
425
|
+
description: 'Stop when the pull request is merged',
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
id: 'ci_passing',
|
|
429
|
+
name: 'CI Passing',
|
|
430
|
+
description: 'Stop when CI checks pass',
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
};
|
|
434
|
+
},
|
|
383
435
|
};
|
|
384
436
|
}
|
|
@@ -169,4 +169,13 @@ export class AgentOrchestratorClient {
|
|
|
169
169
|
async deleteSubagentTranscript(sessionId, transcriptId) {
|
|
170
170
|
await this.request('DELETE', `/sessions/${sessionId}/subagent_transcripts/${transcriptId}`);
|
|
171
171
|
}
|
|
172
|
+
// MCP Servers
|
|
173
|
+
async getMcpServers() {
|
|
174
|
+
const response = await this.request('GET', '/mcp_servers');
|
|
175
|
+
return response.mcp_servers;
|
|
176
|
+
}
|
|
177
|
+
// Unified Configs
|
|
178
|
+
async getConfigs() {
|
|
179
|
+
return this.request('GET', '/configs');
|
|
180
|
+
}
|
|
172
181
|
}
|
package/shared/resources.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
-
|
|
2
|
+
import type { IAgentOrchestratorClient } from './orchestrator-client/orchestrator-client.js';
|
|
3
|
+
export type ClientFactory = () => IAgentOrchestratorClient;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a function to register all resources with the server.
|
|
6
|
+
* @param clientFactory - Factory function that creates client instances
|
|
7
|
+
* @returns Function that registers all resources with a server
|
|
8
|
+
*/
|
|
9
|
+
export declare function createRegisterResources(clientFactory: ClientFactory): (server: Server) => void;
|
|
3
10
|
//# sourceMappingURL=resources.d.ts.map
|
package/shared/resources.js
CHANGED
|
@@ -1,67 +1,149 @@
|
|
|
1
1
|
import { ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
resources: [
|
|
13
|
-
{
|
|
14
|
-
uri: 'agent-orchestrator://config',
|
|
15
|
-
name: 'Server Configuration',
|
|
16
|
-
description: 'Current server configuration and status. Useful for debugging and verifying setup.',
|
|
17
|
-
mimeType: 'application/json',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
// Read resource contents
|
|
23
|
-
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
24
|
-
const { uri } = request.params;
|
|
25
|
-
// =========================================================================
|
|
26
|
-
// CONFIG RESOURCE - Server Status and Configuration
|
|
27
|
-
// =========================================================================
|
|
28
|
-
if (uri === 'agent-orchestrator://config') {
|
|
29
|
-
const config = {
|
|
30
|
-
server: {
|
|
31
|
-
name: 'agent-orchestrator-mcp-server',
|
|
32
|
-
version: '0.1.0',
|
|
33
|
-
transport: 'stdio',
|
|
34
|
-
},
|
|
35
|
-
environment: {
|
|
36
|
-
AGENT_ORCHESTRATOR_BASE_URL: process.env.AGENT_ORCHESTRATOR_BASE_URL
|
|
37
|
-
? '***configured***'
|
|
38
|
-
: 'not set',
|
|
39
|
-
AGENT_ORCHESTRATOR_API_KEY: process.env.AGENT_ORCHESTRATOR_API_KEY
|
|
40
|
-
? '***configured***'
|
|
41
|
-
: 'not set',
|
|
42
|
-
ENABLED_TOOLGROUPS: process.env.ENABLED_TOOLGROUPS || 'all (default)',
|
|
43
|
-
SKIP_HEALTH_CHECKS: process.env.SKIP_HEALTH_CHECKS || 'false',
|
|
44
|
-
},
|
|
45
|
-
capabilities: {
|
|
46
|
-
tools: true,
|
|
47
|
-
resources: true,
|
|
48
|
-
},
|
|
49
|
-
toolGroups: {
|
|
50
|
-
readonly: 'Read-only operations (list, get, search)',
|
|
51
|
-
write: 'Write operations (create, update, follow_up, pause, restart, archive, unarchive)',
|
|
52
|
-
admin: 'Administrative operations (delete)',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
2
|
+
import { getConfigsCache, setConfigsCache } from './cache/configs-cache.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function to register all resources with the server.
|
|
5
|
+
* @param clientFactory - Factory function that creates client instances
|
|
6
|
+
* @returns Function that registers all resources with a server
|
|
7
|
+
*/
|
|
8
|
+
export function createRegisterResources(clientFactory) {
|
|
9
|
+
return (server) => {
|
|
10
|
+
// List available resources
|
|
11
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
55
12
|
return {
|
|
56
|
-
|
|
13
|
+
resources: [
|
|
57
14
|
{
|
|
58
15
|
uri: 'agent-orchestrator://config',
|
|
16
|
+
name: 'Server Configuration',
|
|
17
|
+
description: 'Current server configuration and status. Useful for debugging and verifying setup.',
|
|
18
|
+
mimeType: 'application/json',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
uri: 'agent-orchestrator://configs/mcp-servers',
|
|
22
|
+
name: 'Available MCP Servers',
|
|
23
|
+
description: 'List of available MCP servers that can be used with start_session.',
|
|
24
|
+
mimeType: 'application/json',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
uri: 'agent-orchestrator://configs/agent-roots',
|
|
28
|
+
name: 'Agent Roots',
|
|
29
|
+
description: 'Preconfigured repository settings with default branch, MCP servers, and stop conditions.',
|
|
30
|
+
mimeType: 'application/json',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
uri: 'agent-orchestrator://configs/stop-conditions',
|
|
34
|
+
name: 'Stop Conditions',
|
|
35
|
+
description: 'Available session completion criteria for use with start_session.',
|
|
59
36
|
mimeType: 'application/json',
|
|
60
|
-
text: JSON.stringify(config, null, 2),
|
|
61
37
|
},
|
|
62
38
|
],
|
|
63
39
|
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
40
|
+
});
|
|
41
|
+
// Read resource contents
|
|
42
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
43
|
+
const { uri } = request.params;
|
|
44
|
+
// =========================================================================
|
|
45
|
+
// CONFIG RESOURCE - Server Status and Configuration
|
|
46
|
+
// =========================================================================
|
|
47
|
+
if (uri === 'agent-orchestrator://config') {
|
|
48
|
+
const config = {
|
|
49
|
+
server: {
|
|
50
|
+
name: 'agent-orchestrator-mcp-server',
|
|
51
|
+
version: '0.2.0',
|
|
52
|
+
transport: 'stdio',
|
|
53
|
+
},
|
|
54
|
+
environment: {
|
|
55
|
+
AGENT_ORCHESTRATOR_BASE_URL: process.env.AGENT_ORCHESTRATOR_BASE_URL
|
|
56
|
+
? '***configured***'
|
|
57
|
+
: 'not set',
|
|
58
|
+
AGENT_ORCHESTRATOR_API_KEY: process.env.AGENT_ORCHESTRATOR_API_KEY
|
|
59
|
+
? '***configured***'
|
|
60
|
+
: 'not set',
|
|
61
|
+
ENABLED_TOOLGROUPS: process.env.ENABLED_TOOLGROUPS || 'all (default)',
|
|
62
|
+
SKIP_HEALTH_CHECKS: process.env.SKIP_HEALTH_CHECKS || 'false',
|
|
63
|
+
},
|
|
64
|
+
capabilities: {
|
|
65
|
+
tools: true,
|
|
66
|
+
resources: true,
|
|
67
|
+
},
|
|
68
|
+
toolGroups: {
|
|
69
|
+
readonly: 'Read-only operations (list, get, search)',
|
|
70
|
+
write: 'Write operations (create, update, follow_up, pause, restart, archive, unarchive)',
|
|
71
|
+
admin: 'Administrative operations (delete)',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
contents: [
|
|
76
|
+
{
|
|
77
|
+
uri: 'agent-orchestrator://config',
|
|
78
|
+
mimeType: 'application/json',
|
|
79
|
+
text: JSON.stringify(config, null, 2),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// =========================================================================
|
|
85
|
+
// CONFIGS RESOURCES - Static configuration from API
|
|
86
|
+
// =========================================================================
|
|
87
|
+
if (uri.startsWith('agent-orchestrator://configs/')) {
|
|
88
|
+
// Fetch configs (using cache if available)
|
|
89
|
+
const configs = await fetchConfigs(clientFactory);
|
|
90
|
+
if (uri === 'agent-orchestrator://configs/mcp-servers') {
|
|
91
|
+
return {
|
|
92
|
+
contents: [
|
|
93
|
+
{
|
|
94
|
+
uri,
|
|
95
|
+
mimeType: 'application/json',
|
|
96
|
+
text: JSON.stringify({
|
|
97
|
+
mcp_servers: configs.mcp_servers,
|
|
98
|
+
_usage: 'Use the "name" field when specifying mcp_servers in start_session',
|
|
99
|
+
}, null, 2),
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (uri === 'agent-orchestrator://configs/agent-roots') {
|
|
105
|
+
return {
|
|
106
|
+
contents: [
|
|
107
|
+
{
|
|
108
|
+
uri,
|
|
109
|
+
mimeType: 'application/json',
|
|
110
|
+
text: JSON.stringify({
|
|
111
|
+
agent_roots: configs.agent_roots,
|
|
112
|
+
_usage: 'Use the "git_root" field when starting sessions. Default settings will be applied automatically.',
|
|
113
|
+
}, null, 2),
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (uri === 'agent-orchestrator://configs/stop-conditions') {
|
|
119
|
+
return {
|
|
120
|
+
contents: [
|
|
121
|
+
{
|
|
122
|
+
uri,
|
|
123
|
+
mimeType: 'application/json',
|
|
124
|
+
text: JSON.stringify({
|
|
125
|
+
stop_conditions: configs.stop_conditions,
|
|
126
|
+
_usage: 'Use the "id" field when specifying stop_condition in start_session',
|
|
127
|
+
}, null, 2),
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`Resource not found: ${uri}`);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetch configs from API, using cache if available.
|
|
139
|
+
*/
|
|
140
|
+
async function fetchConfigs(clientFactory) {
|
|
141
|
+
const cached = getConfigsCache();
|
|
142
|
+
if (cached) {
|
|
143
|
+
return cached;
|
|
144
|
+
}
|
|
145
|
+
const client = clientFactory();
|
|
146
|
+
const configs = await client.getConfigs();
|
|
147
|
+
setConfigsCache(configs);
|
|
148
|
+
return configs;
|
|
67
149
|
}
|
package/shared/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createRegisterResources } from './resources.js';
|
|
3
3
|
import { createRegisterTools } from './tools.js';
|
|
4
4
|
import { AgentOrchestratorClient, } from './orchestrator-client/orchestrator-client.js';
|
|
5
5
|
export function createMCPServer() {
|
|
6
6
|
const server = new Server({
|
|
7
7
|
name: 'agent-orchestrator-mcp-server',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.2.0',
|
|
9
9
|
}, {
|
|
10
10
|
capabilities: {
|
|
11
11
|
resources: {},
|
|
@@ -26,6 +26,7 @@ export function createMCPServer() {
|
|
|
26
26
|
}
|
|
27
27
|
return new AgentOrchestratorClient(baseUrl, apiKey);
|
|
28
28
|
});
|
|
29
|
+
const registerResources = createRegisterResources(factory);
|
|
29
30
|
registerResources(server);
|
|
30
31
|
const registerTools = createRegisterTools(factory);
|
|
31
32
|
registerTools(server);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { IAgentOrchestratorClient } from '../orchestrator-client/orchestrator-client.js';
|
|
4
|
+
export declare const GetConfigsSchema: z.ZodObject<{
|
|
5
|
+
force_refresh: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
force_refresh?: boolean | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
force_refresh?: boolean | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function getConfigsTool(_server: Server, clientFactory: () => IAgentOrchestratorClient): {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
force_refresh: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: never[];
|
|
23
|
+
};
|
|
24
|
+
handler: (args: unknown) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
} | {
|
|
30
|
+
content: {
|
|
31
|
+
type: string;
|
|
32
|
+
text: string;
|
|
33
|
+
}[];
|
|
34
|
+
isError: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=get-configs.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getConfigsCache, setConfigsCache } from '../cache/configs-cache.js';
|
|
3
|
+
export const GetConfigsSchema = z.object({
|
|
4
|
+
force_refresh: z
|
|
5
|
+
.boolean()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('Force refresh the cache and fetch fresh data from the API. Default: false'),
|
|
8
|
+
});
|
|
9
|
+
const TOOL_DESCRIPTION = `Fetches all static configuration data in a single call.
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
- **MCP servers**: Available servers for use with start_session (name, title, description)
|
|
13
|
+
- **Agent roots**: Preconfigured repository settings with defaults (git_root, branch, mcp_servers, stop_condition)
|
|
14
|
+
- **Stop conditions**: Available session completion criteria (id, name, description)
|
|
15
|
+
|
|
16
|
+
**Use this tool** to get all configuration options before calling start_session.
|
|
17
|
+
|
|
18
|
+
**Caching:** Results are cached in memory for the session. Use force_refresh=true to fetch fresh data.`;
|
|
19
|
+
export function getConfigsTool(_server, clientFactory) {
|
|
20
|
+
return {
|
|
21
|
+
name: 'get_configs',
|
|
22
|
+
description: TOOL_DESCRIPTION,
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
force_refresh: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description: 'Force refresh the cache and fetch fresh data from the API. Default: false',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: [],
|
|
32
|
+
},
|
|
33
|
+
handler: async (args) => {
|
|
34
|
+
try {
|
|
35
|
+
const validatedArgs = GetConfigsSchema.parse(args);
|
|
36
|
+
const forceRefresh = validatedArgs.force_refresh ?? false;
|
|
37
|
+
// Use cached data if available and not forcing refresh
|
|
38
|
+
const cachedConfigs = getConfigsCache();
|
|
39
|
+
if (cachedConfigs !== null && !forceRefresh) {
|
|
40
|
+
return formatResponse(cachedConfigs, true);
|
|
41
|
+
}
|
|
42
|
+
// Fetch fresh data using unified configs endpoint
|
|
43
|
+
const client = clientFactory();
|
|
44
|
+
const configs = await client.getConfigs();
|
|
45
|
+
// Update shared cache
|
|
46
|
+
setConfigsCache(configs);
|
|
47
|
+
return formatResponse(configs, false);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: `Error fetching configs: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: true,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function formatResponse(configs, fromCache) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
// MCP Servers section
|
|
66
|
+
lines.push('## MCP Servers');
|
|
67
|
+
lines.push('');
|
|
68
|
+
if (configs.mcp_servers.length === 0) {
|
|
69
|
+
lines.push('*No MCP servers available.*');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
lines.push(`Found ${configs.mcp_servers.length} server${configs.mcp_servers.length === 1 ? '' : 's'}:`);
|
|
73
|
+
lines.push('');
|
|
74
|
+
for (const server of configs.mcp_servers) {
|
|
75
|
+
formatMcpServer(lines, server);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Agent Roots section
|
|
79
|
+
lines.push('---');
|
|
80
|
+
lines.push('');
|
|
81
|
+
lines.push('## Agent Roots');
|
|
82
|
+
lines.push('');
|
|
83
|
+
if (configs.agent_roots.length === 0) {
|
|
84
|
+
lines.push('*No agent roots configured.*');
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
lines.push(`Found ${configs.agent_roots.length} preconfigured repositor${configs.agent_roots.length === 1 ? 'y' : 'ies'}:`);
|
|
88
|
+
lines.push('');
|
|
89
|
+
for (const root of configs.agent_roots) {
|
|
90
|
+
formatAgentRoot(lines, root);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Stop Conditions section
|
|
94
|
+
lines.push('---');
|
|
95
|
+
lines.push('');
|
|
96
|
+
lines.push('## Stop Conditions');
|
|
97
|
+
lines.push('');
|
|
98
|
+
if (configs.stop_conditions.length === 0) {
|
|
99
|
+
lines.push('*No stop conditions defined.*');
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
lines.push(`Found ${configs.stop_conditions.length} stop condition${configs.stop_conditions.length === 1 ? '' : 's'}:`);
|
|
103
|
+
lines.push('');
|
|
104
|
+
for (const condition of configs.stop_conditions) {
|
|
105
|
+
formatStopCondition(lines, condition);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Usage hints
|
|
109
|
+
lines.push('---');
|
|
110
|
+
lines.push('');
|
|
111
|
+
lines.push('### Usage Notes');
|
|
112
|
+
lines.push('');
|
|
113
|
+
lines.push('- Use `name` values from **MCP Servers** in `start_session` `mcp_servers` parameter');
|
|
114
|
+
lines.push('- Use `git_root` from **Agent Roots** to start sessions with preconfigured defaults');
|
|
115
|
+
lines.push('- Use `id` values from **Stop Conditions** in `start_session` `stop_condition` parameter');
|
|
116
|
+
if (fromCache) {
|
|
117
|
+
lines.push('');
|
|
118
|
+
lines.push('*(Returned from cache. Use `force_refresh: true` to fetch fresh data.)*');
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function formatMcpServer(lines, server) {
|
|
125
|
+
lines.push(`### ${server.title}`);
|
|
126
|
+
lines.push(`- **Name:** \`${server.name}\``);
|
|
127
|
+
lines.push(`- **Description:** ${server.description}`);
|
|
128
|
+
lines.push('');
|
|
129
|
+
}
|
|
130
|
+
function formatAgentRoot(lines, root) {
|
|
131
|
+
lines.push(`### ${root.title}`);
|
|
132
|
+
lines.push(`- **Name:** \`${root.name}\``);
|
|
133
|
+
lines.push(`- **Git Root:** \`${root.git_root}\``);
|
|
134
|
+
lines.push(`- **Description:** ${root.description}`);
|
|
135
|
+
if (root.default_branch) {
|
|
136
|
+
lines.push(`- **Default Branch:** \`${root.default_branch}\``);
|
|
137
|
+
}
|
|
138
|
+
if (root.default_subdirectory) {
|
|
139
|
+
lines.push(`- **Default Subdirectory:** \`${root.default_subdirectory}\``);
|
|
140
|
+
}
|
|
141
|
+
if (root.default_mcp_servers && root.default_mcp_servers.length > 0) {
|
|
142
|
+
lines.push(`- **Default MCP Servers:** ${root.default_mcp_servers.map((s) => `\`${s}\``).join(', ')}`);
|
|
143
|
+
}
|
|
144
|
+
if (root.default_stop_condition) {
|
|
145
|
+
lines.push(`- **Default Stop Condition:** \`${root.default_stop_condition}\``);
|
|
146
|
+
}
|
|
147
|
+
lines.push('');
|
|
148
|
+
}
|
|
149
|
+
function formatStopCondition(lines, condition) {
|
|
150
|
+
lines.push(`### ${condition.name}`);
|
|
151
|
+
lines.push(`- **ID:** \`${condition.id}\``);
|
|
152
|
+
lines.push(`- **Description:** ${condition.description}`);
|
|
153
|
+
lines.push('');
|
|
154
|
+
}
|
|
@@ -15,8 +15,8 @@ export declare const StartSessionSchema: z.ZodObject<{
|
|
|
15
15
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
16
|
custom_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
title?: string | undefined;
|
|
19
18
|
agent_type?: string | undefined;
|
|
19
|
+
title?: string | undefined;
|
|
20
20
|
prompt?: string | undefined;
|
|
21
21
|
git_root?: string | undefined;
|
|
22
22
|
branch?: string | undefined;
|
|
@@ -28,8 +28,8 @@ export declare const StartSessionSchema: z.ZodObject<{
|
|
|
28
28
|
config?: Record<string, unknown> | undefined;
|
|
29
29
|
custom_metadata?: Record<string, unknown> | undefined;
|
|
30
30
|
}, {
|
|
31
|
-
title?: string | undefined;
|
|
32
31
|
agent_type?: string | undefined;
|
|
32
|
+
title?: string | undefined;
|
|
33
33
|
prompt?: string | undefined;
|
|
34
34
|
git_root?: string | undefined;
|
|
35
35
|
branch?: string | undefined;
|
|
@@ -32,6 +32,8 @@ export const StartSessionSchema = z.object({
|
|
|
32
32
|
});
|
|
33
33
|
const TOOL_DESCRIPTION = `Start a new agent session in the Agent Orchestrator.
|
|
34
34
|
|
|
35
|
+
**IMPORTANT:** Before starting a session, call get_configs to discover available MCP servers, stop conditions, and preconfigured agent roots.
|
|
36
|
+
|
|
35
37
|
**Returns:** The created session with its ID, status, and configuration.
|
|
36
38
|
|
|
37
39
|
**Behavior:**
|
package/shared/tools.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
// Simplified tool surface -
|
|
2
|
+
// Simplified tool surface - 5 tools
|
|
3
3
|
import { searchSessionsTool } from './tools/search-sessions.js';
|
|
4
4
|
import { startSessionTool } from './tools/start-session.js';
|
|
5
5
|
import { getSessionTool } from './tools/get-session.js';
|
|
6
6
|
import { actionSessionTool } from './tools/action-session.js';
|
|
7
|
+
import { getConfigsTool } from './tools/get-configs.js';
|
|
7
8
|
const ALL_TOOL_GROUPS = ['readonly', 'write', 'admin'];
|
|
8
9
|
/**
|
|
9
10
|
* Parse enabled tool groups from environment variable.
|
|
@@ -31,11 +32,13 @@ export function parseEnabledToolGroups(enabledGroupsParam) {
|
|
|
31
32
|
* - start_session: Create a new session
|
|
32
33
|
* - get_session: Get detailed session info with optional logs/transcripts
|
|
33
34
|
* - action_session: Perform actions (follow_up, pause, restart, archive, unarchive)
|
|
35
|
+
* - get_configs: Fetch all static configuration (MCP servers, agent roots, stop conditions)
|
|
34
36
|
*/
|
|
35
37
|
const ALL_TOOLS = [
|
|
36
38
|
// Read operations
|
|
37
39
|
{ factory: searchSessionsTool, groups: ['readonly', 'write', 'admin'] },
|
|
38
40
|
{ factory: getSessionTool, groups: ['readonly', 'write', 'admin'] },
|
|
41
|
+
{ factory: getConfigsTool, groups: ['readonly', 'write', 'admin'] },
|
|
39
42
|
// Write operations
|
|
40
43
|
{ factory: startSessionTool, groups: ['write', 'admin'] },
|
|
41
44
|
{ factory: actionSessionTool, groups: ['write', 'admin'] },
|
package/shared/types.d.ts
CHANGED
|
@@ -98,6 +98,34 @@ export interface ApiError {
|
|
|
98
98
|
message?: string;
|
|
99
99
|
messages?: string[];
|
|
100
100
|
}
|
|
101
|
+
export interface MCPServerInfo {
|
|
102
|
+
name: string;
|
|
103
|
+
title: string;
|
|
104
|
+
description: string;
|
|
105
|
+
}
|
|
106
|
+
export interface MCPServersResponse {
|
|
107
|
+
mcp_servers: MCPServerInfo[];
|
|
108
|
+
}
|
|
109
|
+
export interface AgentRootInfo {
|
|
110
|
+
name: string;
|
|
111
|
+
title: string;
|
|
112
|
+
description: string;
|
|
113
|
+
git_root: string;
|
|
114
|
+
default_branch?: string;
|
|
115
|
+
default_subdirectory?: string;
|
|
116
|
+
default_stop_condition?: string;
|
|
117
|
+
default_mcp_servers?: string[];
|
|
118
|
+
}
|
|
119
|
+
export interface StopConditionInfo {
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
description: string;
|
|
123
|
+
}
|
|
124
|
+
export interface ConfigsResponse {
|
|
125
|
+
mcp_servers: MCPServerInfo[];
|
|
126
|
+
agent_roots: AgentRootInfo[];
|
|
127
|
+
stop_conditions: StopConditionInfo[];
|
|
128
|
+
}
|
|
101
129
|
export interface CreateSessionRequest {
|
|
102
130
|
agent_type?: string;
|
|
103
131
|
prompt?: string;
|