Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maplezzk/mcps",
"version": "1.1.5",
"version": "1.1.6",
"description": "A CLI to manage and use MCP servers",
"publishConfig": {
"access": "public"
Expand Down
5 changes: 4 additions & 1 deletion src/commands/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ const startAction = async (options: any) => {
env: {
...process.env,
MCPS_DAEMON_DETACHED: 'true',
MCPS_VERBOSE: options.verbose ? 'true' : 'false'
MCPS_VERBOSE: options.verbose ? 'true' : 'false',
MCPS_CONNECTION_TIMEOUT: String((parseInt(options.connectionTimeout || process.env.MCPS_CONNECTION_TIMEOUT || '20', 10)) * 1000)
}
});

Expand Down Expand Up @@ -445,6 +446,7 @@ export const registerDaemonCommand = (program: Command) => {
.description('Start the daemon')
.option('-p, --port <number>', 'Daemon port', String(DAEMON_PORT))
.option('-t, --timeout <seconds>', 'Startup timeout in seconds (default: 30)')
.option('-c, --connection-timeout <seconds>', 'Server connection timeout in seconds (default: 20)')
.option('-v, --verbose', 'Show detailed logs')
.action((options) => startAction(options));

Expand Down Expand Up @@ -473,6 +475,7 @@ export const registerDaemonCommand = (program: Command) => {
daemonCmd.command('start', { isDefault: true, hidden: true })
.description('Start the daemon (default)')
.option('-t, --timeout <seconds>', 'Startup timeout in seconds (default: 30)')
.option('-c, --connection-timeout <seconds>', 'Server connection timeout in seconds (default: 20)')
.action((options) => startAction(options));

daemonCmd.command('stop')
Expand Down
5 changes: 4 additions & 1 deletion src/core/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export class ConnectionPool {

const verbose = process.env.MCPS_VERBOSE === 'true';

// 获取连接超时时间(从环境变量或默认 20 秒)
const connectionTimeout = parseInt(process.env.MCPS_CONNECTION_TIMEOUT || '20000', 10);

// 过滤掉 disabled 的服务器
const enabledServers = servers.filter(server => {
const disabled = (server as any).disabled === true;
Expand All @@ -110,7 +113,7 @@ export class ConnectionPool {
for (const server of enabledServers) {
process.stdout.write(`- ${server.name}... `);
try {
await this.getClient(server.name, { timeoutMs: 8000 });
await this.getClient(server.name, { timeoutMs: connectionTimeout });
results.push({ name: server.name, success: true });
console.log('Connected ✓');
} catch (error: any) {
Expand Down