# Using AI Patterns from an agent

## MCP server

- URL: https://aipatterns.dev/mcp
- Transport: Streamable HTTP (MCP 2026-07-28, with stateless fallback for 2025-era clients). No session state. Read-only.
- Authentication: OAuth 2.1 with PKCE - browser clients start the sign-in flow automatically on first connect. Quota: 100 tool calls per user per 24h window, anchored to signup.

```bash
claude mcp add --transport http aipatterns https://aipatterns.dev/mcp
```

```json
{ "mcpServers": { "aipatterns": { "type": "http", "url": "https://aipatterns.dev/mcp" } } }
```

Tools: `search`, `get_entry`, `get_section`, `list_entries`, `recommend`, `get_examples`, `check_pattern_fit`, `grill_pattern`, `compare_patterns`, `find_refactorings`, `get_refactoring_steps`, `detect_smells`, `get_smell_treatment`. Resources: `aipatterns://entry/{slug}` and `aipatterns://index`.

## Plain HTTP

- Append `.md` to any page URL, or send `Accept: text/markdown`.
- `https://aipatterns.dev/llms.txt` is the index, and `https://aipatterns.dev/llms-full.txt` has every entry in one file.

## Rules for agents

1. Name the problem (a smell, or a force that hurts) before reaching for a pattern.
2. Read "Do not use it when" before "Use it when".
3. Intending to implement a pattern: call `grill_pattern` (or run the aipatterns-grill skill) - inspect the code and existing infrastructure, then settle scale, reliability and budget questions with the user before writing code.
4. Prefer a language feature (function values, generics, sum types) over a pattern that emulates it.
5. Refactor in small, behavior-preserving steps, and run the tests after each one.
6. Cite the entry URL in your explanation.
