notes
README.md
# claude-notes-agent

An MCP server that exposes a folder of markdown notes as 4 tools, plus a guarded
Claude Code agent that answers questions from those notes with citations.
Built by **Abhishek Koti** to put the **Claude AI** concepts and
domains into practice: tool design and MCP, Claude Code configuration, agentic
architecture, and reliability through evals.

## What it shows
| Area | Where to look |
| --- | --- |
| Tool design & MCP | `server.py`, `notes_core.py` |
| Claude Code configuration | `CLAUDE.md`, `.claude/` |
| Guardrails (hooks, permissions) | `.claude/settings.json`, `hooks/` |
| Agent loop internals | `agent_loop.py`, `tests/test_agent_loop.py` |
| Reliability (evals) | `evals/` |
## Architecture
```mermaid
flowchart LR
U[You] -->|/ask-notes| CC[Claude Code]
CC -->|delegates| SA[notes-librarian subagent]
SA -->|tool call| PRE{PreToolUse hook}
PRE -->|allowed| MCP[notes MCP server]
PRE -->|blocked| SA
MCP --> CORE[notes_core.py]
CORE --> N[(sample_notes)]
MCP -->|result| POST[PostToolUse hook]
POST --> LOG[(logs/tool_calls.jsonl)]
POST --> SA
```
A question goes to Claude Code, which delegates to a subagent that has only the
four notes tools. Every write passes a guard hook before it reaches the MCP
server, and every tool call is logged.
## Quick start (Windows)
1. Install [uv](https://docs.astral.sh/uv/) and Claude Code (v2.1.295 or later), and
log Claude Code in with a Claude subscription. No API key is needed.
2. Clone and install:
```powershell
git clone https://github.com/Abhishek-Koti/claude-notes-agent.git
cd claude-notes-agent
uv sync
```
3. Run the tests: `uv run pytest` (26 tests)
4. Run `claude` in the project folder, approve the `notes` MCP server, then type
`/ask-notes when is the MVP deadline?`
## Design decisions
- **4 tools, not more.** Fewer, sharper tools make tool selection more reliable.
The descriptions chain them explicitly: search first, then read.
- **Errors tell the model what to do next**, for example
"Call search_notes or list_recent_notes to get valid paths", so the agent can recover on its own.
- **Logic separated from transport.** `notes_core.py` is plain, fully tested Python;
`server.py` is a thin MCP wrapper, so the same logic works in any MCP client.
- **Guardrails in code, not prompts.** A PreToolUse hook blocks secrets and fails
closed (if the hook breaks, saving is blocked rather than allowed). Writes always
ask a human, reads are pre-approved, and every call is logged.
- **Least privilege.** The subagent gets only the 4 notes tools; the hand-written
agent loop gets only the 2 read-only ones.
- **Context protection.** Result caps, short snippets, note truncation, and a
subagent with its own context window.
- **Runs on a subscription.** Claude Code is the agent runtime, so there is no
API spend. The hand-written loop is tested with a fake model, so its tests are free
and deterministic.
## Guardrails in action

The agent was willing to save the note; nothing in the prompt stopped it.
The hook did. Prompts are requests, hooks are guarantees.
## Evals
**8/8 passing** (see `evals/last_run.json`). Each question runs through headless
Claude Code and is scored on two things: the right fact and the right note cited.
One question can't be answered from the notes, and the agent must say so rather than guess.

What I changed after failures:
- **`not-in-notes` failed even though the agent behaved correctly.** It said
"your notes don't say" instead of an exact phrase. I widened the accepted
phrasings rather than forcing exact wording in the prompt, because the behaviour,
not the wording, is what matters.
- **`dark-mode` passed, then failed on a later run** because the agent wrote
"isn't part" instead of "not part". Instead of adding phrases one by one, I made
the scorer normalize contractions, which fixed that whole class of failure.
- **Lesson:** agent wording varies from run to run, so I run the full set twice
before trusting a result.
## Works in any MCP client
The same server answers in Claude Desktop with no code changes:

## Limitations and next steps
- Keyword search, not semantic search; next step is embeddings-based search.
- Local stdio transport only; a remote deployment would need HTTP transport with authentication.
- The secret check is pattern-based; it catches common key and password formats, not every secret.
- Evals use phrase matching; a model-graded check would handle wording variation more robustly.
## License
MITThis server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues