debugging-troubleshooting

A set of practical rules for finding and diagnosing software problems, including TypeScript errors and MCP server issues. It covers logging, error details, type checking, and server inspection.

In plain words
What is it for?
Use it when debugging an application or an MCP server, reading logs, tracing errors, checking TypeScript types, or investigating why an MCP tool is not registered correctly.
Why use it?
It gives developers a consistent way to investigate failures instead of guessing. It also helps separate missing tool setup, invalid inputs, and type errors.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/lazylagom/context-compose-mcp/debugging-troubleshooting
Clone the repo
git clone --depth 1 https://github.com/lazylagom/context-compose-mcp

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,008 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01008
Opus 5 $0.00000 $0.00504
Sonnet 5 $0.00000 $0.00202
Haiku 4.5 $0.00000 $0.00101

Measured 2d ago against content hash a38de5a86d50, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

debugging-troubleshooting scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf node_modules pnpm-lock.yaml
.cursor/rules/debugging-troubleshooting.mdc · 192 lines

How it starts

The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Debugging and Troubleshooting Guide

General Debugging Strategies

Logging and Console Output

  • Development Mode: Output debugging information using console.log
  • Structured Logging: Structured log messages in JSON format
  • Error Stack Tracing: Include detailed error information and stack traces

TypeScript Type Errors

  • Type Checking: Check entire project types with npm run type-check
  • Gradual Type Application: Minimize any type usage and define specific types
  • Type Guards: Ensure type safety at runtime

MCP Server Debugging

MCP Server Inspection Tools

# Inspect MCP server under development
npm run inspect

# Inspect built MCP server
npm run inspect:built

Common MCP Issues

1. Tool Registration Failure
// Incorrect example
server.tool('invalid-tool', {
  // Missing parameter schema
}, handler);

// Correct example
server.tool('valid-tool', {
  description: 'Clear description',
  parameters: z.object({
    param: z.string().describe('Parameter description')
  })
}, handler);
2. Type Mismatch Issues
  • Zod Schema Validation: Type validation of input parameters
  • TypeScript Type Definitions: Compile-time type safety
3. Asynchronous Processing Errors
// Properly handle Promise chains
server.tool('async-tool', schema, async (params) => {
  try {
    const result = await someAsyncOperation(params);
    return { result };
  } catch (error) {
    throw new Error(`Operation failed: ${error.message}`);
  }
});

CLI Debugging

CLI Command Testing

# Run CLI in local development mode
npm run context-compose -- --help

# Debug specific commands
npm run context-compose -- get-context default --verbose

Common CLI Issues

1. Command Parsing Errors
  • Commander.js Configuration Check: Review command definitions in src/cli/index.ts
  • Argument Validation: Distinguish between required and optional arguments

Read the full file on GitHub · 192 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 192 lines · 0 tokens per session scan C a38de5a86d50

Subscribe to this mod's changes

debugging-troubleshooting is a cursor rule published in the GitHub repository lazylagom/context-compose-mcp (1 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,008 tokens. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.