Gathering detailed insights and metrics for huggingface-mcp-server
Gathering detailed insights and metrics for huggingface-mcp-server
Gathering detailed insights and metrics for huggingface-mcp-server
Gathering detailed insights and metrics for huggingface-mcp-server
npm install huggingface-mcp-server
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A TypeScript-based MCP (Model, Chat, Protocol) server that integrates with HuggingFace's inference endpoints to provide:
This server implements the OpenAI API protocol for tools, making it compatible with tool-enabled LLM clients.
Before others can use this package with npx, you need to publish it to npm:
1# Create an npm account if you don't have one 2npm adduser 3 4# Login to npm 5npm login 6 7# Publish the package 8npm publish
When updating the package with new features:
package.json
, claude-mcp.json
, and src/cli.ts
npm run build
npm publish
The prepublishOnly
script will ensure the project is built before publishing.
Once published, you can install this package globally:
1npm install -g huggingface-mcp-server
Then run it using:
1hf-mcp-server --api-key YOUR_HUGGINGFACE_API_KEY
Run it directly with npx without installing:
1npx huggingface-mcp-server --api-key YOUR_HUGGINGFACE_API_KEY
Clone this repository
Install dependencies:
npm install
Copy environment file and configure it:
cp .env.example .env
Update the .env
file with your HuggingFace API key.
Build and run the server:
npm run build
npm start
Or run in development mode:
npm run dev
This project includes MCP configuration files for easy integration with various AI assistants:
Use the claude-mcp.json
file in the Claude Desktop MCP configuration settings.
Use the cursor-mcp.json
file in the Cursor MCP settings.
Add the contents of cline-mcp.json
to your Cline configuration:
1{ 2 "huggingface-mcp": { 3 "command": "npx", 4 "args": [ 5 "--yes", 6 "huggingface-mcp-server@latest", 7 "--api-key=YOUR_HUGGINGFACE_API_KEY_HERE", 8 "--port=3000" 9 ], 10 "disabled": false, 11 "timeout": 60 12 } 13}
Make sure to replace YOUR_HUGGINGFACE_API_KEY_HERE
with your actual API key.
All configurations will start the server and require your HuggingFace API key.
Options:
-p, --port <number> Port to run the HTTP server on (default: "3000")
-k, --api-key <string> HuggingFace API key
-e, --env <path> Path to .env file
-t, --transport <type> Transport type (http or stdio) (default: "http")
-h, --help display help for command
Example using HTTP transport:
1npx huggingface-mcp-server --port 4000 --api-key YOUR_API_KEY
Example using stdio transport:
1npx huggingface-mcp-server --transport stdio --api-key YOUR_API_KEY
You can also set the transport via environment variables:
1TRANSPORT=stdio npx huggingface-mcp-server --api-key YOUR_API_KEY
When running in HTTP mode, the following endpoints are available:
Returns a health check message indicating the server is running.
Returns the list of available tools:
generate_image
: Generate an image with optional custom LoRAgenerate_story
: Generate a story based on a promptMain endpoint that handles the MCP protocol for tool usage.
When running in stdio mode, the server communicates using JSON messages through standard input/output:
1{"type": "tools"}
1{ 2 "type": "chat", 3 "data": { 4 "messages": [ 5 { 6 "role": "user", 7 "content": "Generate an image of a cat" 8 } 9 ] 10 } 11}
1{"type": "exit"}
Example request to generate an image:
1{ 2 "messages": [ 3 { 4 "role": "user", 5 "content": "I want to generate an image of a cat in space" 6 }, 7 { 8 "role": "assistant", 9 "tool_calls": [ 10 { 11 "id": "call_123", 12 "type": "function", 13 "function": { 14 "name": "generate_image", 15 "arguments": "{\"prompt\": \"A cat in space with a space helmet, stars in background\", \"lora_name\": \"username/space-cats-lora\"}" 16 } 17 } 18 ] 19 } 20 ] 21}
Example request to generate a story:
1{ 2 "messages": [ 3 { 4 "role": "user", 5 "content": "Write me a story about a space explorer" 6 }, 7 { 8 "role": "assistant", 9 "tool_calls": [ 10 { 11 "id": "call_456", 12 "type": "function", 13 "function": { 14 "name": "generate_story", 15 "arguments": "{\"prompt\": \"A space explorer discovers an ancient alien civilization\"}" 16 } 17 } 18 ] 19 } 20 ] 21}
MIT
No vulnerabilities found.
No security vulnerabilities found.