Hugging Face Workshop

Hands-on workshop on Hugging Face datasets, models, and tools

Section 2 — Use Hugging Face MCP with Claude Code

In this section we set up access to Claude through a Harvard billing account, then explore how to use the Hugging Face MCP server to search datasets and models directly from Claude Code.

2.1 Access Claude through a Harvard Billing Account

Claude Code is Anthropic's CLI for Claude. For this workshop, access is provided through Harvard's billing account via AWS Bedrock.

Previous session Claude Code setup was covered in detail in a previous workshop. See the full walkthrough at GenAI for Scholarship — Session 3: Power User.

Install Claude Code

If you don't have Claude Code installed:

curl -fsSL https://claude.ai/install.sh | bash

Configure environment variables

Set these environment variables to route Claude Code through the Harvard billing endpoint:

export ANTHROPIC_BEDROCK_BASE_URL=https://apis.huit.harvard.edu/ais-bedrock-llm/v2
export ANTHROPIC_API_KEY=$(cat api_key.txt)
export ANTHROPIC_SMALL_FAST_MODEL=us.anthropic.claude-opus-4-5-20251101-v1:0
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
export CLAUDE_CODE_USE_BEDROCK=1
API key The API key will be provided during the workshop. Store it in a file called api_key.txt and never commit it to version control.

Verify it works

Launch Claude Code and confirm you can interact with it:

claude

Try a simple prompt to verify the connection:

> What model are you?

2.2 Explore MCP-Powered Workflows

MCP (Model Context Protocol) lets Claude Code connect to external tools and data sources. The Hugging Face MCP server gives Claude direct access to search and explore datasets, models, and Spaces on the Hub.

Get a Hugging Face account

If you don't have one yet, sign up for a free account at huggingface.co/join. You just need an email address. This gives you access to the Hub, model cards, dataset viewers, and the MCP server.

Get a Hugging Face token

The HF MCP server requires authentication. Once logged in, go to huggingface.co/settings/tokens and create a new token (the default "read" permissions are sufficient).

Configure the Hugging Face MCP server

Add the hosted HF MCP server to Claude Code:

claude mcp add hf-mcp-server \
  -t http https://huggingface.co/mcp \
  -H "Authorization: Bearer <YOUR_HF_TOKEN>"
Quick setup You can also go to huggingface.co/settings/mcp while logged in, select your client, and copy the generated configuration snippet.

Verify it was added:

claude mcp list

See the available tools

Inside Claude Code, type /mcp to open the MCP dialog. This shows all connected servers and the tools they provide. For the HF MCP server, you should see tools like:

What is MCP? MCP (Model Context Protocol) is an open standard that lets AI assistants connect to external tools and data sources. When you add an MCP server, Claude gains new capabilities — in this case, the ability to search and read Hugging Face Hub resources directly.

Try it: search for datasets

Launch Claude Code and ask it to search the Hub:

> Search Hugging Face for image segmentation datasets related to tree cover

Claude will use the MCP server to query the Hub and return matching datasets, including cards, metadata, and download counts.

Try it: search for models

> Find SegFormer models on Hugging Face that are fine-tuned for semantic segmentation

Try it: read a model card

> Read the model card for restor/tcd-segformer-mit-b0 and summarize the training details

Try it: compare models

> Compare the model cards of nvidia/segformer-b0-finetuned-ade-512-512 and restor/tcd-segformer-mit-b0. What are the key differences in training data, number of classes, and intended use?
Why MCP matters Without MCP, you'd need to manually browse the Hub, copy URLs, and paste information into your conversation. With the HF MCP server, Claude can search, read, and reason about Hub resources in a single workflow — making exploration faster and more interactive.

Next: Run Models in Minutes →