Skip to content

Commit 2b36f95

Browse files
committed
feat: include tools and resources in MCP server info
1 parent 4145aca commit 2b36f95

5 files changed

Lines changed: 52 additions & 14 deletions

File tree

report-app/src/app/pages/report-viewer/report-viewer.html

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ <h4>Servers</h4>
219219
<ul>
220220
@for (server of details.mcp.servers; track server) {
221221
<li>
222-
<span>
222+
<div>
223223
<strong>{{ server.name }}</strong
224224
>:
225225
<code
@@ -228,7 +228,27 @@ <h4>Servers</h4>
228228
{{ arg }}
229229
}
230230
</code>
231-
</span>
231+
</div>
232+
@if (server.tools && server.tools.length > 0) {
233+
<div>
234+
Tools
235+
<ul>
236+
@for (tool of server.tools; track tool) {
237+
<li>{{ tool }}</li>
238+
}
239+
</ul>
240+
</div>
241+
}
242+
@if (server.resources && server.resources.length > 0) {
243+
<div>
244+
Resources
245+
<ul>
246+
@for (tool of server.resources; track tool) {
247+
<li>{{ tool }}</li>
248+
}
249+
</ul>
250+
</div>
251+
}
232252
</li>
233253
}
234254
</ul>

runner/codegen/genkit/genkit-runner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
LlmGenerateTextResponse,
1212
LlmGenerateTextRequestOptions,
1313
LlmGenerateFilesRequestOptions,
14+
McpServerDetails,
1415
} from '../llm-runner.js';
1516
import {setTimeout} from 'node:timers/promises';
1617
import {callWithTimeout} from '../../utils/timeout.js';
@@ -193,7 +194,7 @@ export class GenkitRunner implements LlmRunner {
193194
}
194195
}
195196

196-
startMcpServerHost(hostName: string, servers: McpServerOptions[]): void {
197+
async startMcpServerHost(hostName: string, servers: McpServerOptions[]): Promise<McpServerDetails> {
197198
if (this.mcpHost !== null) {
198199
throw new Error('MCP host is already started');
199200
}
@@ -210,6 +211,12 @@ export class GenkitRunner implements LlmRunner {
210211

211212
globalLogger.startCapturingLogs();
212213
this.mcpHost = createMcpHost({name: hostName, mcpServers});
214+
const tools = await this.mcpHost.getActiveTools(this.genkitInstance);
215+
const resources = await this.mcpHost.getActiveResources(this.genkitInstance);
216+
return {
217+
tools: tools.map((t) => t.__action.name),
218+
resources: resources.map((r) => r.__action.name),
219+
};
213220
}
214221

215222
flushMcpServerLogs(): string[] {

runner/codegen/llm-runner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ export interface LlmRunner {
4646
* Optional since not all runners may support MCP.
4747
* @param hostName Name for the MCP host.
4848
* @param servers Configured servers that should be started.
49+
* @returns Details about the created server.
4950
*/
50-
startMcpServerHost?(hostName: string, servers: McpServerOptions[]): void;
51+
startMcpServerHost?(hostName: string, servers: McpServerOptions[]): Promise<McpServerDetails>;
5152

5253
/** Stops tracking MCP server logs and returns the current ones. */
5354
flushMcpServerLogs?(): string[];
@@ -179,6 +180,12 @@ export const mcpServerOptionsSchema = z.object({
179180
/** Options used to start an MCP server. */
180181
export type McpServerOptions = z.infer<typeof mcpServerOptionsSchema>;
181182

183+
/** Details about an MCP server. */
184+
export interface McpServerDetails {
185+
tools: string[];
186+
resources: string[];
187+
}
188+
182189
/**
183190
* Type for a prompt message may be passed to LLM runner in the eval tool.
184191
*

runner/orchestration/generate.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,16 @@ export async function generateCodeAndAssess(options: {
125125
// We need Chrome to collect runtime information.
126126
await installChrome();
127127

128-
if (
129-
env instanceof LocalEnvironment &&
130-
options.startMcp &&
131-
env.mcpServerOptions.length &&
132-
env.llm.startMcpServerHost
133-
) {
134-
env.llm.startMcpServerHost(`mcp-${env.clientSideFramework.id}`, env.mcpServerOptions);
135-
}
128+
const mcpServerDetails =
129+
env instanceof LocalEnvironment &&
130+
options.startMcp &&
131+
env.mcpServerOptions.length &&
132+
env.llm.startMcpServerHost
133+
? await env.llm.startMcpServerHost(
134+
`mcp-${env.clientSideFramework.id}`,
135+
env.mcpServerOptions
136+
)
137+
: undefined;
136138

137139
progress.initialize(promptsToProcess.length);
138140

@@ -228,7 +230,9 @@ export async function generateCodeAndAssess(options: {
228230
name: m.name,
229231
command: m.command,
230232
args: m.args,
231-
})),
233+
tools: mcpServerDetails?.tools || [],
234+
resources: mcpServerDetails?.resources || [],
235+
})),
232236
logs: env.llm.flushMcpServerLogs().join('\n'),
233237
}
234238
: undefined;

runner/shared-interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export interface RunDetails {
391391
/** Information about configured MCP servers, if any. */
392392
mcp?: {
393393
/** MCP servers that were configured. */
394-
servers: {name: string; command: string; args: string[]}[];
394+
servers: {name: string; command: string; args: string[], tools: string[], resources: string[]}[];
395395

396396
/** Logs produced by all of the servers. */
397397
logs: string;

0 commit comments

Comments
 (0)