agenticscope

agenticscope

A read-only MCP server that provides AI agents with live, structured workspace awareness, including project listing, git status, and budgeted context packing, minimizing token usage.

Category
访问服务器

README

agenticscope

A directory-as-context standard plus a read-only MCP server that gives any AI agent live, structured awareness of your workspace — without burning your tokens re-reading everything.

Status: Draft 0.1.0 · License: MIT · Requires: Node.js ≥ 22


Why I built this

I kept hitting the same wall.

Every AI coding tool I used — Claude Code, Cursor, Gemini, ChatGPT — wanted me to hand it context. So I did what everyone does: I wrote an AGENTS.md, a CLAUDE.md, a .cursorrules. Then those files grew. Soon a single "context file" held my coding standards, my database schema, my architecture decisions, my current task notes, and a persona prompt — all stacked into one wall of text.

Then I saw what was actually happening under the hood: the agent re-read the whole thing on almost every turn. I'd be tweaking some CSS and the model would drag my entire Postgres schema into context to do it. I paid for that — in tokens, in latency, and in hitting my plan limits faster than I should have.

That frustration started this project. I want my AI tools to know more about my work while reading less of it.

The pain points I set out to kill

I wrote these down first, and they became my design checklist. A monolithic context file:

  1. Wastes tokens. The agent reads irrelevant information — schemas while I touch CSS, deploy notes while I fix a unit test. Most of what loads is noise.
  2. Mixes up priority. When behavioral rules ("never use any") share a file with static reference data (an API spec), the model can't tell a hard rule from background knowledge.
  3. Breeds tool noise. Every vendor wants its own folder — .claude/, .gemini/, .cursor/ — and they drift out of sync.
  4. Ignores the workspace. I work across many repos. Nothing could tell an agent "here's every project, here's which have uncommitted changes, here's what's in flight." Each session started blind.

How I built it

I started cheap and let each pain point push the design forward:

  • I split the monolith into small files — but the agent still over-read, so organization alone didn't fix tokens.
  • I made it an index, not a convention. A tiny agenticscope.toml manifest is the only always-loaded file. It maps triggersfragments, each with a type, priority, and token cost, under a hard budget.
  • I made fragments typed (rule / knowledge / spec / persona) with explicit precedence, so behavioral rules stop drowning in reference dumps.
  • I added a build step that compiles the one .scope/ source into every vendor's native file — edit once, stay in sync.
  • I wrote a read-only MCP server so an agent can ask structured questions about the whole workspace instead of swallowing files.

What agenticscope is

Two parts that work together.

1. The .scope/ standard

A predictable layout for everything an agent needs, driven by a tiny manifest:

my-app/
├── agenticscope.toml      # the manifest — tiny, the only file always loaded
└── .scope/
    ├── rules/             # type: rule      — behavioral, high priority
    ├── knowledge/         # type: knowledge — static reference, lazy
    ├── specs/             # type: spec      — current task requirements
    ├── personas/          # type: persona   — swappable agent "hats"
    └── memory/            # persistent project knowledge (decisions, prefs)

Each fragment matches a task two ways, kept deliberately separate:

  • triggers — glob patterns, matched only against concrete file paths.
  • keywords — plain words, matched (substring, case-insensitive) against the task text.

Splitting them avoids false positives (a glob like **/*.ts never leaks into text matching as "ts" and grabs unrelated words like "artifacts"). A plain-word trigger is also treated as a keyword, so simple words keep working.

[scope]
version    = "0.1.0"
name       = "my-project"
budget     = 4000     # hard cap (estimated tokens) per context pack
precedence = "type"   # ordering: "type" (rules first) or "priority"

[[fragment]]
id       = "coding-rules"
type     = "rule"
path     = ".scope/rules/coding.md"
triggers = ["**/*.ts", "**/*.tsx"]   # file paths
keywords = ["refactor", "lint"]      # task text
priority = 100

[[fragment]]
id       = "db-schema"
type     = "knowledge"
path     = ".scope/knowledge/schema.sql"
triggers = ["**/*.sql", "db/**"]
keywords = ["migration", "schema", "database"]
priority = 20

2. The read-only MCP server

It gives an AI host live, structured awareness of a multi-project workspace. It only reads — it never writes.

Tool What it answers
list_projects Which projects exist in the workspace
list_subagents Which personas/subagents a project defines
list_plans Which plans/specs are in flight
git_status The git state of each repo (branch, ahead/behind, dirty count)
grep_memory A fast grep over .scope/memory/ files
pack_context A task → a token-budgeted set of fragments

How to use it

Install

# Run without installing:
npx agenticscope init

# Or install the CLI + MCP server globally:
npm i -g agenticscope

This gives you two commands: agenticscope (the CLI) and agenticscope-mcp (the server).

Quick start

agenticscope init          # scaffold agenticscope.toml + .scope/ in the current dir
# edit the manifest + fragment files to match your project
agenticscope lint          # validate the manifest and check every fragment path
agenticscope build         # compile .scope/ into CLAUDE.md / GEMINI.md / AGENTS.md / .cursorrules

Pack context for a task

pack resolves a task into a budgeted context block. Only matching fragments load, and only until the budget runs out:

$ agenticscope pack "fix the sql migration" -d ./my-app
► "fix the sql migration" — matched 1 fragment(s) (budget 4000, used 86)
  [knowledge] db-schema             86 tok
  — skipped coding-rules (no trigger match)
  — skipped qa-persona (no trigger match)

<!-- [knowledge] db-schema (86 tok) -->
CREATE TABLE users ( ... );

Pipe the packed context straight into any model — including raw web chats:

agenticscope pack "fix auth bug" --raw | pbcopy   # then paste into ChatGPT, Gemini, etc.

Pass concrete file paths so glob triggers match precisely:

agenticscope pack "refactor handler" -p src/api/handler.ts -p src/db/schema.sql

CLI reference

Command Does
agenticscope init [dir] Scaffold a manifest + .scope/ tree
agenticscope lint [dir] Validate the manifest; flag missing paths, dupe ids, dead fragments
agenticscope build [dir] Compile .scope/ into all vendor files
agenticscope pack <task...> Resolve a task into a budgeted context block (-d dir, -p paths, --raw)

Wire up the MCP server

Point any MCP-capable host at the server and give it your workspace root. The host then calls the tools live.

Claude Code / Claude Desktop — add to your MCP config (.mcp.json or claude_desktop_config.json):

{
  "mcpServers": {
    "agenticscope": {
      "command": "npx",
      "args": ["-y", "agenticscope-mcp", "--workspace", "~/Documents"]
    }
  }
}

The same server works in Gemini (Gemini CLI), ChatGPT / OpenAI agents, Cursor, Zed, and Windsurf — each just has its own config file. You can also set the workspace with the AGENTICSCOPE_WORKSPACE environment variable instead of --workspace.

Once connected, I ask things like "what's in flight across my workspace?" and the host calls list_plans + git_status and answers from structured data — no file dumps, no token burn. That's the whole point delivered.


How you can leverage this

You don't need my exact setup to benefit. There are three ways in.

Use it as-is. Scaffold .scope/ in your projects and point an MCP host at the server. You get progressive, budgeted context and live workspace awareness immediately.

Use it with any vendor.

  • MCP path (live tools): any host that speaks MCP — Claude Code/Desktop, Gemini, ChatGPT/OpenAI agents, Cursor, Zed, Windsurf.
  • CLI path (works everywhere, even raw web chats): build generates each vendor's file from one source; pack prints a budgeted block you can paste into any model.

Use it as a base for your own. Everything here is intentionally simple and MIT-licensed. Fork it and:

  • Define your own fragment types beyond rule/knowledge/spec/persona.
  • Swap the token estimator — it ships with a dependency-free chars/4 heuristic; drop in a real tokenizer if you need exact counts.
  • Add your own MCP tools — the server is read-only by design, but the pattern extends cleanly.
  • Replace the resolver — the trigger/priority/budget model is a starting point, not a cage.

Requirements

  • Node.js ≥ 22 (active LTS; Node 18 and 20 are end-of-life).
  • An AI tool you already use — Claude Code, Claude Desktop, Gemini, ChatGPT/OpenAI, Cursor, etc.
  • No API key, no extra credits. agenticscope runs entirely locally and never calls a model itself. Driving it through Claude Code on a Pro plan needs nothing more — the MCP tools run inside your normal session.

Project layout

agenticscope/
├── src/
│   ├── cli.ts            # init / lint / build / pack
│   ├── core/             # manifest parsing, fragment resolution, token budget, vendor build
│   └── mcp/              # read-only MCP server + tools (workspace scan, git, grep)
└── examples/
    └── sample-workspace/ # a working .scope/ project to try the commands against

Changelog

I keep this log for my own reference — what shipped, what I fixed, and what others contributed. Newest first.

Unreleased

Added

  • Separate keywords (text) from triggers (file-path globs) on each fragment.
  • precedence setting ("type" or "priority") to control fragment ordering.
  • Test suite (Vitest) covering manifest parsing, trigger matching, packing/budget, vendor build, and memory grep.
  • GitHub Actions: CI (typecheck + test + build) and tag-triggered npm publish with provenance.

Fixed

  • Trigger false positives — globs like **/*.ts no longer keyword-match unrelated words such as "artifacts".
  • MCP tool errors now return a clean isError result instead of crashing the server.

0.1.0 — Initial release

Added

  • The .scope/ standard: a agenticscope.toml manifest mapping triggers → typed, priced fragments under a token budget.
  • CLI: init, lint, build, pack.
  • Vendor build: compile one .scope/ source into CLAUDE.md, GEMINI.md, AGENTS.md, and .cursorrules.
  • Read-only MCP server with list_projects, list_subagents, list_plans, git_status, grep_memory, and pack_context.
  • A sample workspace under examples/ to try the commands against.

Fixed

  • Required Node ≥ 22 (Node 18 and 20 are end-of-life).
  • Stopped tracking the .idea/ IDE directory.

When I fix an issue or merge a contribution, I add it here under a new version with Added / Changed / Fixed and link the issue or PR, e.g. - Fixed empty-trigger crash in pack (#12, thanks @contributor).

Contributing

Contributions are welcome.

  • Found a bug or have an idea? Open an issue: https://github.com/jessn-dev/agenticscope/issues
  • Sending a pull request? Fork, branch, run npm run typecheck && npm test before you push, and describe the change. I record merged PRs in the Changelog above.
  • Local setup:
    npm install
    npm run typecheck
    npm test
    npm run dev:cli -- lint examples/sample-workspace/api   # run the CLI from source
    npm run dev:mcp                                          # run the MCP server from source
    

Status & roadmap

This is an early draft (0.1.0). The standard and the MCP tool surface come first; expect the resolver and tooling to keep evolving. Feedback, forks, and competing designs are all welcome — I want a better way to feed agents context, not a walled garden.


I built this because I was tired of watching a context file I never read eat tokens I couldn't spare.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选