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
6 changes: 6 additions & 0 deletions .changeset/add-mcp-debug-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@perstack/runtime": patch
---

Add debug logging for MCP skill startup time

Empty file.
14 changes: 13 additions & 1 deletion packages/runtime/src/skill-manager/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,21 @@ export class McpSkillManager extends BaseSkillManager {
}
env[envName] = this._env[envName]
}
const startTime = Date.now()
console.log(`[MCP] Starting skill ${skill.name}...`)
const { command, args } = this._getCommandArgs(skill)
const transport = new StdioClientTransport({ command, args, env, stderr: "ignore" })
const transport = new StdioClientTransport({ command, args, env, stderr: "pipe" })
if (transport.stderr) {
transport.stderr.on("data", (chunk: Buffer) => {
console.log(`[MCP:${skill.name}:stderr] ${chunk.toString().trim()}`)
})
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Stderr listener attached before process starts, never receives data

The transport.stderr listener is attached at lines 79-82, but the child process isn't spawned until connect() is called at line 85. The StdioClientTransport.stderr property returns the spawned process's stderr stream, which is only available after start() (called internally by connect()). Since transport.stderr is null or undefined before the process starts, the if (transport.stderr) check fails silently, and the stderr listener is never attached. This defeats the main purpose of this PR - stderr output from the MCP skill will never be logged.

Fix in Cursor Fix in Web

const connectStartTime = Date.now()
await this._mcpClient!.connect(transport)
const connectTime = Date.now()
console.log(
`[MCP] Skill ${skill.name} connected in ${connectTime - connectStartTime}ms (total: ${connectTime - startTime}ms)`,
)
if (this._eventListener) {
const serverInfo = this._mcpClient!.getServerVersion()
const event = createRuntimeEvent("skillConnected", this._runId, {
Expand Down