Frontmatter
| id | 7945 |
| title | Refactor: MCP Client Lifecycle and CLI Runner Renaming |
| state | Closed |
| labels | airefactoring |
| assignees | tobiu |
| createdAt | Nov 30, 2025, 1:50 AM |
| updatedAt | Nov 30, 2025, 2:13 AM |
| githubUrl | https://github.com/neomjs/neo/issues/7945 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 7931 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Nov 30, 2025, 2:13 AM |
Refactor: MCP Client Lifecycle and CLI Runner Renaming
tobiu assigned to @tobiu on Nov 30, 2025, 1:50 AM
tobiu added parent issue #7931 on Nov 30, 2025, 1:50 AM

tobiu
Nov 30, 2025, 2:12 AM
Input from Gemini 2.5:
✦ I have completed the refactoring to align the MCP Client Lifecycle and rename the CLI runner.
Deliverables Completed
- Refactor
Neo.ai.mcp.client.Client(ai/mcp/client/Client.mjs):
- Moved connection logic from the
connect()method intoinitAsync().- Removed the
connect()method entirely.- Added
configFileconfig and integrated config loading intoinitAsync().- The client now correctly self-connects and ensures readiness when
await client.ready()is called.- Rename and Refactor CLI Runner:
- Renamed
ai/mcp/client/mcp-stdio.mjstoai/mcp/client/mcp-cli.mjs.- Updated the runner script to use the new Client lifecycle (
await Neo.create(Client, ...).ready()).- The runner now correctly executes CLI actions and closes the client.
- Update
package.json:
- Modified the
ai:mcp-clientNPM script to point toai/mcp/client/mcp-cli.mjs.- Refactor
Neo.ai.Agent(ai/Agent.mjs):
- Removed the
connect()method.- Moved client creation,
client.ready()calls, and tool aggregation logic intoAgent.initAsync().- Ensured
this.clientsis correctly populated.- Update
ai/agents/mcp-demo-agent.mjs:
- Refactored to use
await agent.ready()instead ofawait agent.connect().- Verified all client and agent interactions.
This refactoring ensures architectural consistency across the client and server components and aligns the lifecycle management with
Neo.core.Baseprinciples.
tobiu closed this issue on Nov 30, 2025, 2:13 AM
Refactor the MCP Client architecture to ensure clear separation of concerns, consistent lifecycle management, and appropriate naming.
Deliverables
Refactor
Neo.ai.mcp.client.Client(ai/mcp/client/Client.mjs):connect()toinitAsync(). The client should self-connect during initialization.connect()should be removed or made private.configFileconfig. InsideinitAsync, callClientConfig.load(this.configFile)if provided, before resolving server details.this.tools) are created duringinitAsync.Rename and Refactor CLI Runner:
ai/mcp/client/mcp-stdio.mjstoai/mcp/client/mcp-cli.mjs.await Neo.create(Client, ...).ready()).client.listTools()orclient.tools.x(), logging results) inside this runner script.client.close()is called before exit.Update
package.json:ai:mcp-clientscript to point toai/mcp/client/mcp-cli.mjs.Refactor
Neo.ai.Agent(ai/Agent.mjs):connect()method.client.ready()calls, and tool aggregation logic intoAgent.initAsync().Agentitself will then be ready when itsinitAsynccompletes.Update
ai/agents/mcp-demo-agent.mjs:await agent.ready()instead ofawait agent.connect().