KosmoKrator

ai

Hugging Face MCP Integration for LangChain

Connect Hugging Face to LangChain through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.

6 functions 5 read 1 write Bearer token auth

Connect Hugging Face to LangChain

Bridge LangChain agents to local KosmoKrator integration tools through MCP or headless CLI calls.

Use the MCP gateway when the agent should discover tools, or wrap kosmo integrations:call for fixed chains. The gateway is local, scoped to this integration, and starts with --write=deny so LangChain can inspect read-capable tools without receiving write access by default.

Hugging Face MCP Config for LangChain

Keep the gateway scoped to the integration and operation class needed by the chain.

{
  "mcpServers": {
    "kosmokrator-hugging-face": {
      "type": "stdio",
      "command": "kosmo",
      "args": [
        "mcp:serve",
        "--integration=hugging-face",
        "--write=deny"
      ]
    }
  }
}

Run the Gateway Manually

kosmokrator mcp:serve --integration=hugging-face --write=deny

Why Use KosmoKrator Here

Scoped tools

Expose only Hugging Face instead of a broad multi-service tool list.

Local credentials

Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.

Write policy

Start read-only, then opt into ask or allow for trusted workspaces.

Hugging Face Tools Visible to LangChain

LangChain sees stable MCP tool names generated from the Hugging Face integration catalog.

MCP toolSource functionTypeDescription
integration__hugging_face__huggingface_list_models hugging-face.huggingface_list_models Read Search and list AI models on the Hugging Face Hub. Filter by text search, author, task (e.g. "text-generation", "image-classification"), tags, and sort by downloads, likes, or recent activity.
integration__hugging_face__huggingface_get_model hugging-face.huggingface_get_model Read Get detailed information about a specific Hugging Face model, including its card, tags, pipeline tag, library, downloads, likes, and file listing.
integration__hugging_face__huggingface_list_datasets hugging-face.huggingface_list_datasets Read Search and list datasets on the Hugging Face Hub. Filter by text search, author, tags, and sort by downloads, likes, or recent activity.
integration__hugging_face__huggingface_inference hugging-face.huggingface_inference Write Run inference on a Hugging Face model via the serverless Inference API. Supports text generation, summarization, translation, classification, image analysis, and more. The payload structure depends on the model's task — refer to the Hugging Face Inference API docs for model-specific formats.
integration__hugging_face__huggingface_list_spaces hugging-face.huggingface_list_spaces Read Search and list Spaces on the Hugging Face Hub. Filter by text search, author, tags, SDK, and sort by downloads, likes, or recent activity.
integration__hugging_face__huggingface_get_current_user hugging-face.huggingface_get_current_user Read Get the authenticated Hugging Face user's profile information, including name, username, type (user/org), and avatar.

Related Hugging Face Pages