Примечание.
Второй пилот SDK в настоящее время находится в Technical Preview. Функциональность и доступность могут меняться.
Quick diagnostics
Checklist
Before diving deep, verify these basics:
- MCP server executable exists and is runnable
- Command path is correct (use absolute paths when in doubt)
- Tools are enabled (
tools: ["*"]or specific tool names) - Server implements MCP protocol correctly (responds to
initialize) - No firewall or antivirus is blocking the process (Windows)
Enable MCP debug logging
Add environment variables to your MCP server config:
mcpServers: {
"my-server": {
type: "local",
command: "/path/to/server",
args: [],
env: {
MCP_DEBUG: "1",
DEBUG: "*",
NODE_DEBUG: "mcp", // For Node.js MCP servers
},
},
}
mcpServers: {
"my-server": {
type: "local",
command: "/path/to/server",
args: [],
env: {
MCP_DEBUG: "1",
DEBUG: "*",
NODE_DEBUG: "mcp", // For Node.js MCP servers
},
},
}
Testing MCP servers independently
Always test your MCP server outside the SDK first.
Manual protocol test
Send an initialize request via stdin:
# Unix/macOS
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | /path/to/your/mcp-server
# Unix/macOS
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | /path/to/your/mcp-server
Expected response:
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"your-server","version":"1.0"}}}
For a Windows PowerShell example, see MCP Server Debugging Guide in the github/copilot-sdk repository.
Test tool listing
After initialization, request the tools list:
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | /path/to/your/mcp-server
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | /path/to/your/mcp-server
Expected response:
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"my_tool","description":"Does something","inputSchema":{...}}]}}
Interactive testing script
Create a test script to interactively debug your MCP server:
#!/bin/bash
# test-mcp.sh
SERVER="$1"
# Initialize
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
# Send initialized notification
echo '{"jsonrpc":"2.0","method":"notifications/initialized"}'
# List tools
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
# Keep stdin open
cat
#!/bin/bash
# test-mcp.sh
SERVER="$1"
# Initialize
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
# Send initialized notification
echo '{"jsonrpc":"2.0","method":"notifications/initialized"}'
# List tools
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
# Keep stdin open
cat
Usage:
./test-mcp.sh | /path/to/mcp-server
./test-mcp.sh | /path/to/mcp-server
Common issues
Server not starting
Symptoms: No tools appear, no errors in logs.
| Cause | Solution |
|---|---|
| Wrong command path | Use absolute path: /usr/local/bin/server |
| Missing executable permission | Run chmod +x /path/to/server |
| Missing dependencies | Check with ldd (Linux) or run manually |
| Working directory issues | Set cwd in config |
Debug by running manually:
# Run exactly what the SDK would run cd /expected/working/dir /path/to/command arg1 arg2
# Run exactly what the SDK would run
cd /expected/working/dir
/path/to/command arg1 arg2
Server starts but tools don't appear
Symptoms: Server process runs but no tools are available.
-
Tools not enabled in config:
TypeScript mcpServers: { "server": { // ... tools: ["*"], // Must be "*" or list of tool names }, }mcpServers: { "server": { // ... tools: ["*"], // Must be "*" or list of tool names }, } -
Server doesn't expose tools: Test with a
tools/listrequest manually. Check that the server implements thetools/listmethod. -
Initialization handshake fails: The server must respond to
initializecorrectly and handlenotifications/initialized.
Tools listed but never called
Symptoms: Tools appear in debug logs but the model doesn't use them.
-
Prompt doesn't clearly need the tool:
TypeScript // Too vague await session.sendAndWait({ prompt: "What's the weather?" }); // Better—explicitly mentions capability await session.sendAndWait({ prompt: "Use the weather tool to get the current temperature in Seattle" });// Too vague await session.sendAndWait({ prompt: "What's the weather?" }); // Better—explicitly mentions capability await session.sendAndWait({ prompt: "Use the weather tool to get the current temperature in Seattle" }); -
Tool description unclear:
TypeScript // Bad—model doesn't know when to use it { name: "do_thing", description: "Does a thing" } // Good—clear purpose { name: "get_weather", description: "Get current weather conditions for a city. Returns temperature, humidity, and conditions." }// Bad—model doesn't know when to use it { name: "do_thing", description: "Does a thing" } // Good—clear purpose { name: "get_weather", description: "Get current weather conditions for a city. Returns temperature, humidity, and conditions." } -
Tool schema issues: Ensure
inputSchemais valid JSON Schema. Required fields must be listed in therequiredarray.
Timeout errors
Symptoms: MCP tool call timed out errors.
-
Increase the timeout:
TypeScript mcpServers: { "slow-server": { // ... timeout: 300000, // 5 minutes }, }mcpServers: { "slow-server": { // ... timeout: 300000, // 5 minutes }, } -
Optimize server performance by adding progress logging to identify the bottleneck, considering async operations, and checking for blocking I/O.
-
For long-running tools, consider streaming responses if supported.
JSON-RPC errors
Symptoms: Parse errors, invalid request errors.
Common causes:
-
Server writes to stdout incorrectly: Debug output going to stdout instead of stderr, or extra newlines or whitespace:
TypeScript // Wrong—pollutes stdout console.log("Debug info"); // Correct—use stderr for debug console.error("Debug info");// Wrong—pollutes stdout console.log("Debug info"); // Correct—use stderr for debug console.error("Debug info"); -
Encoding issues: Ensure UTF-8 encoding with no BOM (Byte Order Mark).
-
Message framing: Each message must be a complete JSON object, newline-delimited (one message per line).
Platform-specific issues
Windows
On Windows, antivirus or firewall software may block new executables or processes communicating via stdin/stdout. Add exclusions for your MCP server executable if needed.
For Windows-specific configuration examples for .NET console apps and NPX commands, see MCP Server Debugging Guide in the github/copilot-sdk repository.
Path issues:
- Use raw strings (
@"C:\path") or forward slashes ("C:/path"). - Avoid spaces in paths when possible.
- If spaces are required, ensure proper quoting.
macOS
-
Gatekeeper blocking: If the server is blocked:
Bash xattr -d com.apple.quarantine /path/to/mcp-server
xattr -d com.apple.quarantine /path/to/mcp-server -
Homebrew paths: GUI apps may not have
/opt/homebrewin PATH. Use the full path:TypeScript mcpServers: { "my-server": { command: "/opt/homebrew/bin/node", // Full path args: ["/path/to/server.js"], }, }mcpServers: { "my-server": { command: "/opt/homebrew/bin/node", // Full path args: ["/path/to/server.js"], }, }
Linux
-
Permission issues:
Bash chmod +x /path/to/mcp-server
chmod +x /path/to/mcp-server -
Missing shared libraries:
Bash # Check dependencies ldd /path/to/mcp-server # Install missing libraries apt install libfoo # Debian/Ubuntu yum install libfoo # RHEL/CentOS
# Check dependencies ldd /path/to/mcp-server # Install missing libraries apt install libfoo # Debian/Ubuntu yum install libfoo # RHEL/CentOS
Advanced debugging
Capture all MCP traffic
Create a wrapper script to log all communication:
#!/bin/bash # mcp-debug-wrapper.sh LOG="/tmp/mcp-debug-$(date +%s).log" ACTUAL_SERVER="$1" shift echo "=== MCP Debug Session ===" >> "$LOG" echo "Server: $ACTUAL_SERVER" >> "$LOG" echo "Args: $@" >> "$LOG" echo "=========================" >> "$LOG" # Tee stdin/stdout to log file tee -a "$LOG" | "$ACTUAL_SERVER" "$@" 2>> "$LOG" | tee -a "$LOG"
#!/bin/bash
# mcp-debug-wrapper.sh
LOG="/tmp/mcp-debug-$(date +%s).log"
ACTUAL_SERVER="$1"
shift
echo "=== MCP Debug Session ===" >> "$LOG"
echo "Server: $ACTUAL_SERVER" >> "$LOG"
echo "Args: $@" >> "$LOG"
echo "=========================" >> "$LOG"
# Tee stdin/stdout to log file
tee -a "$LOG" | "$ACTUAL_SERVER" "$@" 2>> "$LOG" | tee -a "$LOG"
Use it:
mcpServers: {
"debug-server": {
command: "/path/to/mcp-debug-wrapper.sh",
args: ["/actual/server/path", "arg1", "arg2"],
},
}
mcpServers: {
"debug-server": {
command: "/path/to/mcp-debug-wrapper.sh",
args: ["/actual/server/path", "arg1", "arg2"],
},
}
Inspect with MCP Inspector
Use the official MCP Inspector tool:
npx @modelcontextprotocol/inspector /path/to/your/mcp-server
npx @modelcontextprotocol/inspector /path/to/your/mcp-server
This provides a web UI to send test requests, view responses, and inspect tool schemas.
Protocol version mismatches
Check your server supports the protocol version the SDK uses:
// In initialize response, check protocolVersion
{"result":{"protocolVersion":"2024-11-05",...}}
If versions don't match, update your MCP server library.
Debugging checklist
When opening an issue or asking for help on GitHub Issues, collect:
- SDK language and version
- CLI version (
copilot --version) - MCP server type (Node.js, Python, .NET, Go, and so on)
- Full MCP server configuration (redact secrets)
- Result of manual
initializetest - Result of manual
tools/listtest - Debug logs from SDK
- Any error messages