Skip to main content
Glama
theYahia
by theYahia

claude-webcache

npm license downloads

Claude Code用のセッション間WebFetchキャッシュ。

Claude Codeに組み込まれている WebFetch は、単一セッション内で15分間結果をキャッシュします。claude-webcache はこれをセッションをまたいで無期限(TTL 7日、設定可能)に拡張します。

Open new session  ->  your past fetches are still there.
Cache hit         ->  instant.
Cache miss        ->  same as built-in WebFetch.

なぜこれが必要か

セッションをまたいで同じURL(ドキュメント、APIリファレンス、調査ページなど)を再フェッチするたびに、毎回フルフェッチのコストがかかります。15分間のセッション内キャッシュは、次のスプリントが始まる前に期限切れになってしまいます。claude-webcache はフェッチ結果を保持するため、2回目のセッションではキャッシュがヒットします。

CACHE_MISSフロー: 最初のセッションでのWebFetch + cache_store CACHE_HITフロー: 即座にヒット、2回目のセッションではWebFetchなし

Related MCP server: ClaudeX

インストール

オプション1 -- Claude Codeプラグイン(推奨)

ターミナルで以下の1行を実行します:

claude plugin marketplace add theYahia/claude-webcache && claude plugin install claude-webcache@theyahia

次に、~/.claude/CLAUDE.md に使用パターンを追加します(使用パターンを参照)。

💡 なぜTUIの /plugin install ではなくCLIサブコマンドなのか? 現在のTUIフローはClaude Codeの remoteMarketplaceClient バックエンドを経由しますが、これにはサードパーティのプラグインソースをすべて拒否するサーバー側のバグがあり、Failed to install: This plugin uses a source type your Claude Code version does not support. というエラーが発生します。anthropics/claude-code#41653 および関連する約20件のオープンなIssueを参照してください。上記のCLIサブコマンドはローカルで NativeMarketplaceReader を使用するため、影響を受けません。

フォールバック(CLIサブコマンドでもセットアップが失敗する場合):

git clone https://github.com/theYahia/claude-webcache && claude --plugin-dir ./claude-webcache/plugin

これにより、マーケットプレイスのパイプラインを完全にバイパスします。

オプション2 -- npm global

npm i -g @theyahia/claude-webcache

Node.js 22.5+ が必要です(組み込みの node:sqlite を使用するため、ネイティブ依存関係はありません)。

次に、~/.claude/settings.json に手動で登録します(パスは npm root -g の結果に置き換えてください):

{
  "mcpServers": {
    "claude-webcache": {
      "command": "node",
      "args": ["/path/from/npm-root-g/claude-webcache/scripts/mcp-server.cjs"]
    }
  },
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|clear|compact",
        "hooks": [
          { "type": "command", "command": "node /path/from/npm-root-g/claude-webcache/scripts/hook-stats.cjs" }
        ]
      }
    ]
  }
}

オプション3 -- クローン(コントリビューター向け)

CONTRIBUTING.md を参照してください。

使用パターン

~/.claude/CLAUDE.md に追加して、Claudeがキャッシュ経由でWebフェッチを行うようにします:

## WebFetch caching (claude-webcache)

Before calling WebFetch, call `cached_fetch(url, prompt)` first.
- If it returns text -> use that, do NOT call WebFetch.
- If it returns `[CACHE_MISS] <url>` -> call WebFetch as normal, then call `cache_store(url, prompt, output)` with the result.

以上です。今後のセッションで同じURL + 同じプロンプトを使用すれば、即座にキャッシュがヒットします。

ツール (MCP)

ツール

引数

戻り値

cached_fetch

url, prompt

キャッシュされたテキスト、または [CACHE_MISS] <url>

cache_store

url, prompt, output

stored

cache_stats

--

{ total, hits, last }

cache_list

limit?

最近のURL(新しい順)

ストレージ

~/.webcache/cache.db にSQLiteを使用(WALモード、同時実行セーフ)。キャッシュキー = SHA256(url + "|" + prompt)

フィールド

key

TEXT PRIMARY KEY

url

TEXT

prompt_hash

TEXT

output

TEXT

cached_at

INTEGER (ms epoch)

hit_count

INTEGER

last_hit_at

INTEGER

SessionStartフック

新しいセッションごとに、フックが1行の統計情報を挿入します:

webcache: 142 pages cached, 38 hits, last fetch 3h ago

キャッシュが空の場合は挿入をスキップします。

TTL

デフォルトは7日間です。期限切れのエントリは、同じキーが次に読み取られたときに削除されます。src/cache.js を読み込んで purgeExpired() を呼び出すことで、手動でパージを実行できます。

制限事項

  • キャッシュキーにはプロンプトが含まれるため、同じURLでもプロンプトが異なれば別々のエントリになります。ヒット率を最大化するために、一貫したプロンプト(例:常に "extract title and main content")を選択してください。

  • 出力はWebFetchが返すもの(モデルによって既に要約済み)そのままです。キャッシュ側で再処理は行いません。

  • セマンティック検索や埋め込み機能はありません。完全な (url, prompt) 一致のみです。

ライセンス

MIT -- LICENSE を参照してください。

Available Tools

4 tools
cached_fetchA

Look up a URL+prompt pair in the local WebFetch cache. Returns cached output if present (instant), or "[CACHE_MISS] " if not. On CACHE_MISS, call WebFetch, then call cache_store with the result. Same URL+prompt across sessions hits the cache.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to fetch
promptYesThe prompt/instruction for the WebFetch

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Fully describes behavior: cache lookup, instant return on hit, cache miss string, and cross-session caching. Since no annotations are provided, the description carries the full burden and meets it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with purpose, each sentence adds value without redundancy. Fits the required structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Complete for a simple lookup tool: explains input, output, and fallback workflow. No output schema needed as return values are textual and explained.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Adds meaning beyond schema by explaining that url and prompt form a cache key and that prompt is an instruction for WebFetch. Schema coverage is 100%, but description enriches semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it looks up a URL+prompt pair in a local cache, returning cached output or a cache miss message. This distinguishes it from sibling tools like cache_list, cache_stats, and cache_store.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes when to use (check cache) and provides a workflow on cache miss (call WebFetch then cache_store). However, it doesn't explicitly state when not to use or compare directly to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

cache_listB

List recently cached URLs (most recent first).

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMax entries to return (default 50)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It only states the output ordering but does not explain what constitutes 'recently cached', whether the list is global or scoped, or if there are any side effects (e.g., consuming cache entries). No safety or rate-limit information is provided.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that conveys the core purpose with no extraneous words. Every token is meaningful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (1 optional param, no output schema, no nested objects), the description is minimally adequate. However, it could benefit from additional context such as whether the cache is global or per-user, or how 'recent' is defined, but the basic listing functionality is clear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% coverage for the single parameter 'limit', and the description adds no additional meaning beyond what the schema already provides. The baseline score of 3 is appropriate since the schema is sufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a clear verb 'List' and specifies the resource 'recently cached URLs' with ordering 'most recent first'. It distinguishes this from sibling tools like cached_fetch (which likely fetches a specific URL) and cache_store (which stores).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like cached_fetch or cache_stats. There is no mention of prerequisites, use cases, or exclusions. The user is left to infer from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

cache_statsA

Return cache statistics: total entries, total hits, last cached timestamp.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description indicates a read-only operation (returning statistics) with no explicit destructive behavior. However, it lacks disclosure of potential side effects, authentication requirements, or rate limits. Since no annotations are provided, the description carries the full burden, and it only partially meets that need.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that front-loads the purpose ('Return cache statistics') and lists the specific outputs. Every word is necessary and there is no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema), the description is sufficiently complete. It clearly lists the three statistics returned. It could optionally mention that the tool is safe to call at any time, but this is not required for basic completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the description adds no parameter-specific information. According to guidelines, baseline score is 4 when there are 0 parameters, as no compensation is needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool returns cache statistics including total entries, total hits, and last cached timestamp. It uses a specific verb ('Return') and resource ('cache statistics'), and clearly distinguishes from sibling tools like 'cache_list' (which likely returns key listings) and 'cache_store' (which stores items).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus its siblings ('cached_fetch', 'cache_list', 'cache_store'). The description only states what it returns, leaving the agent to infer appropriate usage without explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

cache_storeA

Store a WebFetch result in the cache after a CACHE_MISS. Pass the original url, prompt, and the output text returned by WebFetch.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYes
outputYesThe output text returned by WebFetch
promptYes

TDQS

A3.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only states the storage action but does not mention what happens if the URL already exists (overwrite?), error cases, or authorization needs. This leaves significant ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, consisting of two sentences. The first sentence front-loads the purpose and trigger, and the second lists the parameters. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description provides an adequate but minimal explanation. It identifies the tool's role in caching but omits details about idempotency, error handling, or response format, which would be helpful for a complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is low (33%), but the description adds meaning by associating each parameter with its role: 'original url, prompt, and the output text returned by WebFetch.' This helps clarify the purpose of the url and prompt parameters beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action ('Store a WebFetch result in the cache'), the resource ('cache'), and the trigger condition ('after a CACHE_MISS'). It effectively distinguishes from sibling tools like cached_fetch, cache_list, and cache_stats by specifying its role in the caching workflow.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly specifies when to use the tool (after a CACHE_MISS), providing clear context. However, it does not mention when not to use it or offer alternatives (e.g., using cached_fetch for a subsequent lookup).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.5
    • First observedcache_list
    • First observedcache_stats
    • First observedcache_store
    • First observedcached_fetch

TDQS

A3.9/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a distinct function: lookup, list, stats, store. No overlap in purpose.

Naming Consistency4/5

All tools use 'cache_' prefix, but 'cached_fetch' uses past participle while others use 'cache_' as noun, a minor inconsistency.

Tool Count5/5

4 tools is well-scoped for a caching utility, covering essential operations.

Completeness4/5

Covers lookup, storage, listing, and stats, but lacks a clear operation to clear or invalidate cache entries.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Persistent memory + FTS5 full-text search for Claude Code conversation history. Indexes ~/.claude/projects/ JSONL into SQLite, exposes 10 MCP tools (store/recall/search memories, browse sessions, get summaries) plus prompts. Includes a web UI for visual exploration
    10
    42 npm
    93
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Provides persistent memory, skill tracking, failure indexing, and context sharing for Claude Code using SQLite with FTS5 full-text search.
    23
    6 npm
    1
    MIT