Skip to content

Commit 098ff0a

Browse files
committed
refactor(types): use McpSdkServerConfigWithInstance from Claude Agent SDK
Import the return type directly from @anthropic-ai/claude-agent-sdk instead of maintaining our own ClaudeAgentSdkMcpServer interface. This removes code duplication and ensures type compatibility.
1 parent b7edefd commit 098ff0a

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/tool.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type JSONSchema7 as AISDKJSONSchema, jsonSchema } from 'ai';
22
import type { Tool as AnthropicTool } from '@anthropic-ai/sdk/resources';
3+
import type { McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
34
import * as orama from '@orama/orama';
45
import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
56
import type { FunctionTool as OpenAIResponsesFunctionTool } from 'openai/resources/responses/responses';
@@ -10,7 +11,6 @@ import { RequestBuilder } from './requestBuilder';
1011
import type {
1112
AISDKToolDefinition,
1213
AISDKToolResult,
13-
ClaudeAgentSdkMcpServer,
1414
ClaudeAgentSdkOptions,
1515
ExecuteConfig,
1616
ExecuteOptions,
@@ -450,7 +450,9 @@ export class Tools implements Iterable<BaseTool> {
450450
*
451451
* @see https://docs.anthropic.com/en/docs/agents-and-tools/claude-agent-sdk
452452
*/
453-
async toClaudeAgentSdk(options: ClaudeAgentSdkOptions = {}): Promise<ClaudeAgentSdkMcpServer> {
453+
async toClaudeAgentSdk(
454+
options: ClaudeAgentSdkOptions = {},
455+
): Promise<McpSdkServerConfigWithInstance> {
454456
const { serverName = 'stackone-tools', serverVersion = '1.0.0' } = options;
455457

456458
// Import the Claude Agent SDK dynamically
@@ -476,12 +478,11 @@ export class Tools implements Iterable<BaseTool> {
476478
);
477479

478480
// Create and return the MCP server
479-
// The return type is compatible with McpServerConfig but uses our interface
480481
return claudeAgentSdk.createSdkMcpServer({
481482
name: serverName,
482483
version: serverVersion,
483484
tools: sdkTools,
484-
}) as ClaudeAgentSdkMcpServer;
485+
});
485486
}
486487

487488
/**

src/types.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,6 @@ export type AISDKToolResult<T extends string = string> = ToolSet & {
202202
[K in T]: AISDKToolDefinition;
203203
};
204204

205-
/**
206-
* Claude Agent SDK MCP server configuration returned by toClaudeAgentSdk().
207-
* This type represents the MCP server instance that can be passed to the
208-
* Claude Agent SDK query() function's mcpServers option.
209-
*
210-
* @see https://docs.anthropic.com/en/docs/agents-and-tools/claude-agent-sdk
211-
*/
212-
export interface ClaudeAgentSdkMcpServer {
213-
type: 'sdk';
214-
name: string;
215-
instance: unknown;
216-
}
217-
218205
/**
219206
* Options for toClaudeAgentSdk() method
220207
*/

0 commit comments

Comments
 (0)