Skip to content

Commit be39cb0

Browse files
authored
Merge pull request #4 from mcp-use/feat/ts-python-parity
refactor: Simplify MCPSession by removing unused properties and methods
2 parents 0aebb3e + 2b4ad00 commit be39cb0

File tree

1 file changed

+2
-38
lines changed

1 file changed

+2
-38
lines changed

src/session.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import type { BaseConnector } from './connectors/base.js'
2-
import { logger } from './logging.js'
32

43
export class MCPSession {
54
readonly connector: BaseConnector
65
private autoConnect: boolean
7-
private _sessionInfo: Record<string, any> | null = null
8-
private _tools: Record<string, any>[] = []
96

107
constructor(connector: BaseConnector, autoConnect = true) {
118
this.connector = connector
129
this.autoConnect = autoConnect
1310
}
1411

15-
async open(): Promise<this> {
16-
await this.connect()
17-
return this
18-
}
19-
20-
async close(): Promise<void> {
21-
await this.disconnect()
22-
}
23-
2412
async connect(): Promise<void> {
2513
await this.connector.connect()
2614
}
@@ -29,38 +17,14 @@ export class MCPSession {
2917
await this.connector.disconnect()
3018
}
3119

32-
async initialize(): Promise<Record<string, any>> {
20+
async initialize(): Promise<void> {
3321
if (!this.isConnected && this.autoConnect) {
3422
await this.connect()
3523
}
36-
37-
this._sessionInfo = await this.connector.initialize() ?? {}
38-
await this.discoverTools()
39-
return this._sessionInfo
24+
await this.connector.initialize()
4025
}
4126

4227
get isConnected(): boolean {
4328
return this.connector && this.connector.isClientConnected
4429
}
45-
46-
get sessionInfo(): Record<string, any> | null {
47-
return this._sessionInfo
48-
}
49-
50-
get tools(): Record<string, any>[] {
51-
return this._tools
52-
}
53-
54-
async discoverTools(): Promise<Record<string, any>[]> {
55-
this._tools = this.connector.tools
56-
return this._tools
57-
}
58-
59-
async callTool(name: string, args: Record<string, any>): Promise<any> {
60-
if (!this.isConnected && this.autoConnect) {
61-
await this.connect()
62-
}
63-
logger.debug(`MCPSession calling tool '${name}'`)
64-
return await this.connector.callTool(name, args)
65-
}
6630
}

0 commit comments

Comments
 (0)