workflow

A logging guide for projects that use an MCP server, a service that lets an agent interact with external tools. It requires structured JSON log entries in logs/logs.log with fields such as level, timestamp, and message.

In plain words
What is it for?
Creating the logs folder, writing compliant log records, recording service or user context, and following the project's logging utility or MCP API.
Why use it?
It gives developers one predictable log location and format, making events easier to inspect and process automatically.

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/hassansaadfr/log-reader-mcp/workflow
Clone the repo
git clone --depth 1 https://github.com/hassansaadfr/log-reader-mcp

Made for: Cursor.

Per session 837 This file is loaded in full into every session.
When invoked 837 The same file — it is already loaded in full.
Security scan A 0 findings. 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.00837 $0.00837
Opus 5 $0.00418 $0.00418
Sonnet 5 $0.00167 $0.00167
Haiku 4.5 $0.00084 $0.00084

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

Security

Grade A, and why

workflow scanned grade A with 0 findings 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/log-reader-mcp/workflow.mdc · 90 lines

How it starts

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

MCP Logging Workflow

This guide defines the standards for log management in a project using the MCP server. It is intended for the AI agent and anyone developing on this project.

Log Structure and Location

  • Required folder: Every project must have a logs/ folder at the root.
  • Log file: The main log file must be named logs.log and placed in this folder.

Log Format

  • Structured JSON format: Each line in the logs.log file must be a JSON object following the schema below (see also the definition in @mcp-server.ts):
{
  "level": "INFO|WARN|ERROR|DEBUG|CRITICAL",
  "timestamp": "YYYY-MM-DDTHH:MM:SS.sssZ",
  "message": "string",
  "service_name": "string (optional)",
  "user_id": "string (optional)",
  "context": { ... } (optional),
  "event": { ... } (optional)
}
  • Example:
{
  "level": "INFO",
  "timestamp": "2025-06-01T12:34:56.789Z",
  "message": "User login succeeded",
  "service_name": "auth",
  "user_id": "12345",
  "context": { "ip": "192.168.1.10" },
  "event": { "action": "login" }
}
  • Schema compliance: Always use the project's logging utility function (or the MCP API) to ensure format compliance. Never write directly to the file without validation.

Using the read_log Tool

  • MCP Tool: The server exposes the read_log tool to read the last lines of the log file, with optional time interval filtering.
  • Main arguments:
    • lines: number of lines to read (default: 50)
    • start_time / end_time: optional ISO 8601 time bounds
  • Log file: The server always uses the logs/logs.log file in the user's working directory.
  • Example call:
{
  "tool": "read_log",
  "args": {
    "lines": 100,
    "start_time": "2025-06-01T00:00:00Z",
    "end_time": "2025-06-01T23:59:59Z"
  }
}

Use Cases

Here are several concrete examples of using logs and the read_log tool:

  • Debugging a production error:
    • Read the last 200 lines of the log to identify a sequence of events leading to a critical error.
    • Filter logs over a specific time range to isolate an incident.
  • Verifying a new feature implementation:
    • Check that expected events (e.g., user creation, payment validated) appear in the logs after a deployment.
  • Security audit:
    • Search for failed login attempts or suspicious accesses over a given period.
  • Performance analysis:
    • Extract DEBUG-level logs to measure response times or detect slow endpoints.
  • User support:
    • Retrieve a user's journey (via user_id) to understand a bug or complaint.
  • Automated monitoring:
    • Integrate log reading into a script or external tool to generate alerts in case of detected anomalies.
  • Migration or refactoring validation:
    • Compare logs before/after a migration to ensure no regressions.

Read the full file on GitHub · 90 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 · 90 lines · 837 tokens per session scan A f3c75521059d

Subscribe to this mod's changes

workflow is a cursor rule published in the GitHub repository hassansaadfr/log-reader-mcp (6 stars, last pushed 1y ago), licensed MIT. It adds 837 tokens to every session, about $0.0042 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.