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.
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.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>"
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:
- hub_repo_search — search for models, datasets, and Spaces
- hub_repo_details — get details and README for a specific repo
- paper_search — find ML research papers
- hf_doc_search — search Hugging Face documentation
- space_search — semantic search for Spaces/apps
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?