feat(skill-mcp-manager): improve connection handling and client implementations
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import type { Client } from "@modelcontextprotocol/sdk/client/index.js"
|
||||
import type { Prompt, Resource, Tool } from "@modelcontextprotocol/sdk/types.js"
|
||||
import type { ClaudeCodeMcpServer } from "../claude-code-mcp-loader/types"
|
||||
import { McpOAuthProvider } from "../mcp-oauth/provider"
|
||||
@@ -6,6 +5,7 @@ import { disconnectAll, disconnectSession, forceReconnect } from "./cleanup"
|
||||
import { getOrCreateClient, getOrCreateClientWithRetryImpl } from "./connection"
|
||||
import { handlePostRequestAuthError, handleStepUpIfNeeded } from "./oauth-handler"
|
||||
import type {
|
||||
McpClient,
|
||||
OAuthProviderFactory,
|
||||
SkillMcpClientInfo,
|
||||
SkillMcpManagerState,
|
||||
@@ -36,7 +36,7 @@ export class SkillMcpManager {
|
||||
return `${info.sessionID}:${info.skillName}:${info.serverName}`
|
||||
}
|
||||
|
||||
async getOrCreateClient(info: SkillMcpClientInfo, config: ClaudeCodeMcpServer): Promise<Client> {
|
||||
async getOrCreateClient(info: SkillMcpClientInfo, config: ClaudeCodeMcpServer): Promise<McpClient> {
|
||||
const clientKey = this.getClientKey(info)
|
||||
return await getOrCreateClient({
|
||||
state: this.state,
|
||||
@@ -106,7 +106,7 @@ export class SkillMcpManager {
|
||||
private async withOperationRetry<T>(
|
||||
info: SkillMcpClientInfo,
|
||||
config: ClaudeCodeMcpServer,
|
||||
operation: (client: Client) => Promise<T>
|
||||
operation: (client: McpClient) => Promise<T>
|
||||
): Promise<T> {
|
||||
const maxRetries = 3
|
||||
let lastError: Error | null = null
|
||||
@@ -158,7 +158,7 @@ export class SkillMcpManager {
|
||||
}
|
||||
|
||||
// NOTE: tests spy on this exact method name via `spyOn(manager as any, 'getOrCreateClientWithRetry')`.
|
||||
private async getOrCreateClientWithRetry(info: SkillMcpClientInfo, config: ClaudeCodeMcpServer): Promise<Client> {
|
||||
private async getOrCreateClientWithRetry(info: SkillMcpClientInfo, config: ClaudeCodeMcpServer): Promise<McpClient> {
|
||||
const clientKey = this.getClientKey(info)
|
||||
return await getOrCreateClientWithRetryImpl({
|
||||
state: this.state,
|
||||
|
||||
Reference in New Issue
Block a user