
HAL
io.github.DeanWard由 GitHub 帳號 DeanWard 發布v1.0.14更新於 Nov 3, 2026
HAL (HTTP API Layer) - An MCP server that provides HTTP API capabilities to Large Language Models
概覽
HAL 是本地執行的 MCP 伺服器,讓助理向 Web API 發出 HTTP 請求,支援密鑰替換,並可依 OpenAPI 規格自動產生工具。
- 可以做什麼
- 向任意 URL 送出 GET、POST、PUT、PATCH、DELETE、OPTIONS、HEAD 請求,可自訂標頭、請求內容與內容類型
- 列出可用的密鑰名稱,並在 URL、標頭或請求內容中以佔位符引用,回應中的密鑰值會自動遮蔽
- 從 OpenAPI/Swagger 檔案或 URL 產生可呼叫的工具,每個操作一個,含參數驗證以及路徑、查詢與請求內容處理
- 透過文件資源讀取內建的 API 說明
- 適用情境
- 當助理需要呼叫沒有專用 MCP 伺服器的 REST API 時適用,也適合把整個由 OpenAPI 描述的 API 直接變成現成工具。若希望 API 金鑰不出現在對話中,也可使用。
- 執行需求
- 透過 npx 從 npm 套件 hal-mcp 在本機執行,需要 Node.js 18 或更新版本。選用環境變數可設定 OpenAPI 規格(HAL_SWAGGER_FILE)、基礎 URL(HAL_API_BASE_URL)、密鑰(HAL_SECRET_*)、依命名空間的 URL 限制(HAL_ALLOW_*)以及全域 URL 過濾(HAL_WHITELIST_URLS、HAL_BLACKLIST_URLS)。需要能連線到目標 API 的網路。
安裝
README
HAL (HTTP API Layer)
HAL is a Model Context Protocol (MCP) server that provides HTTP API capabilities to Large Language Models. It allows LLMs to make HTTP requests and interact with web APIs through a secure, controlled interface. HAL can also automatically generate tools from OpenAPI/Swagger specifications for seamless API integration.
Documentation
Visit our comprehensive documentation site for detailed guides, examples, and API reference.
Features
- HTTP GET/POST/PUT/PATCH/DELETE/OPTIONS/HEAD Requests: Fetch and send data to any HTTP endpoint
- Secure Secret Management: Environment-based secrets with
{secrets.key}substitution and automatic redaction - Swagger/OpenAPI Integration: Automatically generate tools from API specifications
- Built-in Documentation: Self-documenting API reference
- Secure: Runs in isolated environment with controlled access
- Fast: Built with TypeScript and optimized for performance
Usage
HAL is designed to work with MCP-compatible clients. Here are some examples:
Basic Usage (Claude Desktop)
Add HAL to your Claude Desktop configuration (npx will automatically install and run HAL):
With Swagger/OpenAPI Integration and Secrets
To enable automatic tool generation from an OpenAPI specification and use secrets:
URL-based Configuration
You can also load OpenAPI specs directly from URLs:
Direct Usage
Configuration
HAL supports the following environment variables:
HAL_SWAGGER_FILE: Path or URL to OpenAPI/Swagger specification file (JSON or YAML format). Can be:- Local file path:
/path/to/api.yaml - Full URL:
https://api.example.com/swagger.json - Relative path:
/swagger/v1/swagger.json(combined withHAL_API_BASE_URL)
- Local file path:
HAL_API_BASE_URL: Base URL for API requests (overrides the servers specified in the OpenAPI spec)HAL_SECRET_*: Secret values for secure substitution in requests (e.g.,HAL_SECRET_TOKEN=abc123)HAL_ALLOW_*: URL restrictions for namespaced secrets (e.g.,HAL_ALLOW_MICROSOFT="https://azure.microsoft.com/*")HAL_WHITELIST_URLS: Comma-separated list of URL patterns that are allowed (if set, only these URLs are permitted)HAL_BLACKLIST_URLS: Comma-separated list of URL patterns that are blocked (if set, these URLs are denied)
Secret Management
HAL provides secure secret management to keep sensitive information like API keys, tokens, and passwords out of the conversation while still allowing the AI to use them in HTTP requests.
How It Works
-
Environment Variables: Define secrets using the
HAL_SECRET_prefix: -
Template Substitution: Reference secrets in your requests using
{secrets.key}syntax:- URLs:
https://api.example.com/data?token={secrets.token} - Headers:
{"Authorization": "Bearer {secrets.api_key}"} - Request Bodies:
{"username": "{secrets.username}", "password": "{secrets.password}"}
- URLs:
-
Security: The AI never sees the actual secret values, only the template placeholders. Values are substituted at request time.
Automatic Secret Redaction
HAL automatically redacts secret values from all responses sent back to the AI, providing an additional layer of security against credential exposure.
How It Works
- Secret Tracking: HAL maintains a registry of all secret values from environment variables
- Response Scanning: All HTTP responses (headers, bodies, error messages) are scanned for secret values
- Automatic Replacement: Any occurrence of actual secret values is replaced with
[REDACTED]before sending to the AI - Comprehensive Coverage: Redaction applies to:
- Error messages (including URL parsing errors that might expose credentials)
- Response headers (in case APIs echo back authentication data)
- Response bodies (protecting against API responses that might include sensitive data)
- All other text returned to the AI
Example Protection
Before (vulnerable):
After (secure):
This protection is automatic and requires no configuration - HAL will redact any secret values regardless of how they appear in responses, ensuring that even if an API or error message attempts to expose credentials, the AI never sees the actual values.
Namespaces and URL Restrictions
HAL supports organizing secrets into namespaces and restricting them to specific URLs for enhanced security:
Namespace Convention
Use - for namespace separators and _ for word separators within keys:
URL Restrictions
Restrict namespaced secrets to specific URLs using HAL_ALLOW_* environment variables:
How Parsing Works
Understanding how environment variable names become template keys:
Step-by-step breakdown:
- Remove
HAL_SECRET_prefix →AZURE-STORAGE_ACCESS_KEY - Split on first
_→ Namespace:AZURE-STORAGE, Key:ACCESS_KEY - Transform namespace:
AZURE-STORAGE→azure.storage(dashes become dots, lowercase) - Transform key:
ACCESS_KEY→access_key(underscores stay, lowercase) - Combine:
{secrets.azure.storage.access_key}
More Examples
Visual Guide: Complete Flow
Security Benefits
- Principle of Least Privilege: Secrets only work with their intended services
- Prevents Cross-Service Leakage: Azure secrets can't be sent to AWS APIs
- Defense in Depth: Even with AI errors or prompt injection, secrets are constrained
- Clear Organization: Namespace structure makes secret management more intuitive
Real-World Usage Scenarios
Scenario 1: Multi-Cloud Application
Usage in requests:
✅ Works: URL matches Azure Storage pattern
❌ Blocked: If used with https://s3.amazonaws.com/bucket - wrong service!
Scenario 2: Development vs Production
Scenario 3: Department Isolation
Error Examples
When URL restrictions are violated, you get clear error messages:
This helps you quickly identify:
- Which secret was blocked
- What URL was attempted
- What URLs are actually allowed
Quick Reference
Pattern: HAL_SECRET_<NAMESPACE>_<KEY> → {secrets.<namespace>.<key>} + HAL_ALLOW_<NAMESPACE>
Backward Compatibility
Non-namespaced secrets (without URL restrictions) continue to work as before:
URL Filtering
HAL supports global URL filtering to control which URLs can be accessed through whitelist or blacklist patterns. This provides an additional security layer beyond the namespace-based secret restrictions.
Whitelist Mode
When HAL_WHITELIST_URLS is set, only URLs matching the specified patterns are allowed:
Blacklist Mode
When HAL_BLACKLIST_URLS is set, all URLs are allowed except those matching the specified patterns:
Pattern Syntax
URL patterns support wildcard matching using *:
https://api.example.com/*- Matches any path under the APIhttps://*.example.com/*- Matches any subdomain*://internal.company.com/*- Matches any protocol
Important Notes
- Whitelist takes precedence: If both
HAL_WHITELIST_URLSandHAL_BLACKLIST_URLSare set, the whitelist is used and a warning is logged - Global filtering: This applies to all HTTP requests, regardless of secrets or tools used
- Case-insensitive: URL pattern matching is case-insensitive
- No filtering by default: If neither environment variable is set, all URLs are allowed
Examples
Example Usage
The {secrets.github_token} will be replaced with the value of HAL_SECRET_GITHUB_TOKEN environment variable before making the request.
Available Tools
Built-in HTTP Tools
These tools are always available regardless of configuration:
list-secrets
Get a list of available secret keys that can be used with {secrets.key} syntax.
Parameters: None
Example Response:
Security Note: Only shows the key names, never the actual secret values.
http-get
Make HTTP GET requests to any URL.
Parameters:
url(string, required): The URL to requestheaders(object, optional): Additional headers to send
Example:
http-post
Make HTTP POST requests with optional body and headers.
Parameters:
url(string, required): The URL to requestbody(string, optional): Request body contentheaders(object, optional): Additional headers to sendcontentType(string, optional): Content-Type header (default: "application/json")
Example:
Auto-generated Swagger/OpenAPI Tools
When you provide a Swagger/OpenAPI specification via HAL_SWAGGER_FILE, HAL will automatically generate tools for each endpoint defined in the specification. These tools are named using the pattern swagger_{operationId} and include:
- Automatic parameter validation based on the OpenAPI schema
- Path parameter substitution (e.g.,
/users/{id}→/users/123) - Query parameter handling
- Request body support for POST/PUT/PATCH operations
- Proper HTTP method mapping
For example, if your OpenAPI spec defines an operation with operationId: "getUser", HAL will create a tool called swagger_getUser that you can use directly.
Available Resources
docs://hal/api
Access comprehensive API documentation and usage examples, including documentation for any auto-generated Swagger tools.
OpenAPI/Swagger Integration Details
Supported OpenAPI Features
- ✅ OpenAPI 3.x and Swagger 2.x specifications
- ✅ JSON and YAML format support
- ✅ Path parameters (
/users/{id}) - ✅ Query parameters
- ✅ Request body (JSON, form-encoded)
- ✅ All HTTP methods (GET, POST, PUT, PATCH, DELETE, etc.)
- ✅ Parameter validation (string, number, boolean, arrays)
- ✅ Required/optional parameter handling
- ✅ Custom headers support
Example OpenAPI Integration
Given this OpenAPI specification:
HAL will automatically create a swagger_getUser tool that the LLM can use like:
This will make a GET request to https://api.example.com/v1/users/123.
Development
Prerequisites
- Node.js 18 or later
- npm or yarn
Setup
Scripts
npm run build- Build the TypeScript projectnpm run dev- Run in development mode with hot reloadnpm start- Start the built servernpm run lint- Run ESLintnpm test- Run tests
Security Considerations
- HAL makes actual HTTP requests to external services
- Use appropriate authentication and authorization for your APIs
- Be mindful of rate limits and API quotas
- Consider network security and firewall rules
- When using Swagger integration, ensure your OpenAPI specifications are from trusted sources
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with the Model Context Protocol TypeScript SDK
- Inspired by the need for LLMs to interact with web APIs safely and efficiently
- OpenAPI integration powered by swagger-parser
來源:README.md,提交 cc02a64
工具
0版本歷史
1- v1.0.14最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分