npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-headers-tool

v2.4.0

Published

MCP server that returns custom application environment variables as headers

Readme

MCP Headers Tool

一个简单的 MCP (Model Context Protocol) 服务器,用于获取自定义应用环境变量(请求头信息)。

功能特点

  • 提供一个 get_headers 工具,无需参数
  • 只返回自定义应用环境变量,自动过滤系统环境变量
  • 自动过滤敏感信息(TOKEN、KEY、SECRET、PASSWORD 等标记为 [REDACTED])
  • 可通过 npx 直接运行,无需全局安装
  • 支持与任何 MCP 兼容的客户端集成

安装

使用 npx(推荐)

无需安装,直接运行:

npx mcp-headers-tool

全局安装

npm install -g mcp-headers-tool

本地安装

npm install mcp-headers-tool

使用方法

1. 在 Claude Desktop 中使用

编辑 Claude Desktop 的配置文件:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

添加以下配置:

{
  "mcpServers": {
    "headers-tool": {
      "command": "npx",
      "args": ["mcp-headers-tool"]
    }
  }
}

2. 在其他 MCP 客户端中使用

配置示例:

{
  "servers": {
    "headers-tool": {
      "command": "npx",
      "args": ["mcp-headers-tool"],
      "env": {}
    }
  }
}

3. 编程方式调用

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { spawn } from 'child_process';

// 创建客户端
const client = new Client({
  name: 'my-mcp-client',
  version: '1.0.0',
}, {
  capabilities: {}
});

// 启动服务器进程
const serverProcess = spawn('npx', ['mcp-headers-tool']);

// 创建传输层
const transport = new StdioClientTransport({
  command: 'npx',
  args: ['mcp-headers-tool']
});

// 连接到服务器
await client.connect(transport);

// 调用工具
const result = await client.callTool({
  name: 'get_headers',
  arguments: {}
});

console.log(result);

工具说明

get_headers

获取自定义应用环境变量(请求头信息)。

参数: 无

返回值: JSON 格式的自定义环境变量对象,其中:

  • 只返回自定义应用环境变量(自动过滤系统环境变量如 PATH、HOME、USER 等)
  • 敏感信息(包含 SECRET、TOKEN、KEY、PASSWORD 的变量)会被标记为 [REDACTED]
  • 其他自定义变量保持原值

过滤规则

  • 排除所有常见系统环境变量
  • 排除 Node.js 相关变量(NODE_、npm_ 前缀)
  • 排除 IDE 相关变量(VSCODE_、CURSOR_ 前缀)
  • 排除其他开发工具变量

示例响应(只包含自定义变量):

{
  "MY_CUSTOM_HEADER": "custom-value",
  "CLIENT_ID": "example-client-123",
  "ENVIRONMENT": "development",
  "USER_AGENT": "MCP-Client/1.0",
  "ACCEPT": "application/json",
  "CONTENT_TYPE": "application/json",
  "AUTHORIZATION": "[REDACTED]",
  "API_KEY": "[REDACTED]",
  "X_REQUEST_ID": "req-12345",
  "X_CUSTOM_HEADER": "custom-header-value"
}

开发

克隆仓库

git clone <repository-url>
cd mcp-headers-tool
npm install

构建

npm run build

开发模式

npm run dev

发布到 NPM

  1. 确保已登录 npm:

    npm login
  2. 更新版本号:

    npm version patch  # 或 minor/major
  3. 发布:

    npm publish

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!

相关链接