Token导航 LogoToken导航TokenDH.com
Dynamic Context MCP logo
开发工具stdio官方级别未说明来源级核验

Dynamic Context MCP

MCP Server

dynamic-context-mcp

一个基于文件和glob模式为AI对话注入即时上下文的模型上下文协议服务器。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
代码生成TypeScriptClaude开发工具Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

nathanbarrett

提供方

nathanbarrett

最后核验

2026/5/17 20:20

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx dynamic-context-mcp init

详细介绍

动态上下文MCP服务器

模型上下文协议(MCP)服务器,根据文件路径和glob模式将“即时”上下文注入AI对话。

🚀 这是什么?

当使用AI编码时,您通常会有特定的指导方针、架构模式或数据库模式,这些仅适用于代码库的某些部分。

动态上下文MCP 允许您在带有glob模式头的Markdown文件中定义这些规则。当AI代理(如Claude或Gemini)查看特定的文件路径时,此工具会自动注入该文件的相关上下文。

示例流程:

  1. 你正在努力 src/backend/api.ts.
  2. 人工智能将此工具称为该路径。
  3. 此服务器找到 backend-guidelines.md (哪个匹配 src/backend/**/*.ts).
  4. 服务器还发现 general-ts-guidelines.md (哪个匹配 *.ts)
  5. 它将所有匹配的上下文文件组合在一起,并将结果传递给您的AI代理 _之前_ 它生成代码

______________________________________________________________________

📦 用法

快速启动(而不是手动设置)

运行init命令自动检测你的框架(Laravel、Next.js、Python),在 .agent/rules,并附加(而不是重写)您的主上下文文件(如 GEMINI.md, CLAUDE.md,或 .cursorrules)有必要的指示。

npx dynamic-context-mcp init

1.准备你的上下文目录

创建文件夹(默认为 .agent/rules)在您的项目根目录中。添加包含YAML frontmatter的markdown文件 globs (单个字符串或列表)。

示例1:单球

文件: .agent/rules/styles.md

---
trigger: glob
globs: "**/*.css"
---

# CSS Rules

- Use flexbox layout.

示例2:多个球体和支架扩展

文件: .agent/rules/frontend.md

---
trigger: glob
globs:
  - "src/helpers/**/*.ts"
  - "resources/js/**/*.{vue,ts}" # Matches both .vue and .ts files
---

# Frontend Rules

- Ensure strict type checking.
- Prefer Composition API for Vue files.

示例3:始终触发

将此用于应适用于的高级规则 _每_ 文件,如通用编码标准或项目理念。

文件: .agent/rules/general.md

---
trigger: always
---

# General Guidelines

- Write clean, commented code.
- Follow SOLID principles.

2.配置您的AI客户端

将其添加到您的MCP配置文件中(例如。, claude_desktop_config.json):

{
  "mcpServers": {
    "dynamic-context": {
      "command": "npx",
      "args": [
        "-y",
        "dynamic-context-mcp",
        "/optional/absolute/path/to/your/project/.agent/rules"
      ]
    }
  }
}

_注意:最后一个参数是可选的。如果省略,则查找 .agent/rules 在MCP服务器运行的目录中。_

3.重要提示:代理配置

为确保您的AI代理有效使用此工具,请在代理的系统提示或自定义说明中添加以下说明(例如 GEMINI.md, CLAUDE.md,或您的代理设置):


## DYNAMIC CONTEXT INSTRUCTIONS

This project uses dynamic context mcp to deliver "just in time" context for files that you are about to read, create, or edit.

**CRITICAL GUIDANCE**

- Before you read, create, or edit a file, check for dynamic context by requesting the `dynamic-context.get_context_for_file` tool with the file path as input.
- If dynamic context is available, read it carefully to understand important details about how to work with that file.
- dynamic context mcp takes a file path as input and goes through all context files that match that path (by glob patterns) to compile relevant context for that file
- file paths must be relative to the project root i.e. `resources/js/components/MyComponent.vue` and NOT `/absolute/path/to/project/resources/js/components/MyComponent.vue`
- dynamic context mcp does NOT take a folder path as input. If no file exists at that path, then you can create a fake file name and extension like `path/to/fakefile.txt` to check for context for that folder.
- Group context for files that have the same path and extension. If you are working with multiple files that have the same path and extension then assume that the compiled context is the same every time and use the same context for all of them.

______________________________________________________________________

🛠 本地开发

如果您想修改或参与此项目:

  1. 克隆仓库:
   git clone 
   cd dynamic-context-mcp
  1. 安装依赖项:
   npm install
  1. 构建项目:
   npm run build
  1. 本地测试:

您可以直接运行编译后的脚本:

   node dist/index.js ./path/to/test/context-folder

______________________________________________________________________

🤝 贡献

欢迎投稿!

  1. 分叉项目
  2. 创建功能分支(git checkout -b feature/AmazingFeature)
  3. 提交您的更改(git commit -m 'Add some AmazingFeature')
  4. 推到分支机构(git push origin feature/AmazingFeature)
  5. 打开拉取请求

📄 许可证

根据MIT许可证分发。

目录标签

目录标签

代码生成TypeScriptClaude开发工具AI开发辅助本地部署上下文管理自动化

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

dynamic-context-mcp

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP