Skip to content

[Tiny-Agent] Switch to VSCode MCP format + fix headers handling #3166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 25, 2025

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jun 17, 2025

EDIT: PR merged and released. Made a release on JS SDK as well and updated all configs in https://huggingface.co/datasets/tiny-agents/tiny-agents.


Currently headers are configured in tiny-agent using servers[].config.options.requestInit.headers (which we inherited from JS MCP client). However it would be preferable to follow VSCode MCP configuration i.e. servers[].headers:

{
  "model": "Qwen/Qwen2.5-72B-Instruct",
  "provider": "nebius",
  "inputs": [
    {
      "type": "promptString",
      "id": "hf-token",
      "description": "Token for Hugging Face API access",
      "password": true
    }
  ],
  "servers": [
    {
      "type": "http",
      "url": "https://huggingface.co/mcp",
      "headers": {
        "Authorization": "Bearer ${input:hf-token}"
      }
    }
  ]
}

I also updated the "default env variable loading" logic. Before we were loading based on the key where the value will be used (in this case Authorization). With the PR, we now build the ENV_VAR based on "input id" hf-token => HF_TOKEN. This is a breaking change but more future-proof IMO

Once approved on this side, I'll make the update in the JS client.


Note: this is orthogonal to the MCP + OAuth topic

EDIT: equivalent PR in JS huggingface/huggingface.js#1556

@Wauplin
Copy link
Contributor Author

Wauplin commented Jun 17, 2025

Working authentication using the example in the PR description:

image

➜ tiny-agents run agent.json
Some initial inputs are required by the agent. Please provide a value or leave empty to load from env.
 • hf-token: Token for Hugging Face API access. (default: load from HF_TOKEN). »  
Value successfully loaded from 'HF_TOKEN'

Agent loaded with 9 tools:
 • hf_whoami
 • space_search
 • model_search
 • model_details
 • paper_search
 • dataset_search
 • dataset_details
 • gr1_evalstate_flux1_schnell
 • gr2_abidlabs_easyghibli
»  what's my account name on HF ?
You are using Hugging Face tools as the authenticated user 'Wauplin'. Therefore, your account name on Hugging Face is **Wauplin**. 

If you need any further assistance or have other questions, feel free to ask!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@Wauplin
Copy link
Contributor Author

Wauplin commented Jun 25, 2025

@hanouticelina I've updated this PR to update the agent.json file format to strictly respect the VSCode file format. No more config, everything is under the root config like this:

    {
      "type": "http",
      "url": "https://huggingface.co/mcp",
      "headers": {
        "Authorization": "Bearer ${input:hf-token}"
      }
    }

this is a breaking change and we'll need to update examples in https://huggingface.co/datasets/tiny-agents/tiny-agents but it's definitely best to do it now rather than later. I'll open the equivalent PR in JS as well.

@Wauplin Wauplin requested a review from hanouticelina June 25, 2025 13:06
Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you!
Added a reminder for myself to update https://huggingface.co/datasets/tiny-agents/tiny-agents when we release the next minor version of hfh.

@Wauplin Wauplin merged commit 6f9b87e into main Jun 25, 2025
26 checks passed
@Wauplin Wauplin deleted the tiny-agents-fix-headers branch June 25, 2025 14:20
@Wauplin Wauplin changed the title [Tiny-Agent] Fix headers handling + secrets management [Tiny-Agent] Switch to VSCode MCP format + fix headers handling Jun 25, 2025
Wauplin added a commit to huggingface/huggingface.js that referenced this pull request Jul 2, 2025
Same PR as huggingface/huggingface_hub#3166 in
Python.

This PR introduces breaking changes but I think it's best to do it now.
Goal is to have the same format as [VSCode MCP
config](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_configuration-format)
e.g.

```json
{
  "model": "Qwen/Qwen2.5-72B-Instruct",
  "provider": "nebius",
  "inputs": [
    {
      "type": "promptString",
      "id": "hf-token",
      "description": "Token for Hugging Face API access",
      "password": true
    }
  ],
  "servers": [
    {
      "type": "http",
      "url": "https://huggingface.co/mcp",
      "headers": {
        "Authorization": "Bearer ${input:hf-token}"
      }
    }
  ]
}
```

breaking changes:
- no more `config` nested mapping => everything at root level
- `headers` at root level instead of inside options.requestInit
- updated the way values are pulled from ENV (based on input id)


Once this PR and
huggingface/huggingface_hub#3166 are approved,
we can merge + release them at the same time + update the config in
https://huggingface.co/datasets/tiny-agents/tiny-agents to follow the
new convention. For now, only
[wauplin/library-pr-reviewer](https://huggingface.co/datasets/tiny-agents/tiny-agents/tree/main/wauplin/library-pr-reviewer)
has been updated for testing.

```
pnpm run cli run wauplin/library-pr-reviewer
```
Wauplin added a commit that referenced this pull request Jul 2, 2025
* [Tiny-Agent] Fix headers handling + secrets management

* no whitespace in id

* switch to VSCode config file format
@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 2, 2025

EDIT: PR merged and released. Made a release on JS SDK as well and updated all configs in https://huggingface.co/datasets/tiny-agents/tiny-agents.

@julien-c
Copy link
Member

julien-c commented Jul 2, 2025

how do you generate the data.parquet file, how of curiosity?

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 2, 2025

how do you generate the data.parquet file, how of curiosity?

Using this script. I wanted to add it in a Space and use webhooks to trigger on each update but never did it in end (so I'm running manually when I think about it). Goal is just to make the dataset viewer work. Would be a good use case of HF CI or Jobs.

import json
from pathlib import Path
from tempfile import TemporaryDirectory

import pandas as pd

from huggingface_hub import snapshot_download, upload_file


DATASET_ID = "tiny-agents/tiny-agents"

CONFIG_FILE = "agent.json"
PROMPT_FILE = "PROMPT.md"
README_FILE = "README.md"

folder = Path(snapshot_download(repo_id=DATASET_ID, repo_type="dataset"))


def load_agent(agent_path: Path):
    """Load agent configuration from a given path."""
    config_path = agent_path / CONFIG_FILE
    prompt_path = agent_path / PROMPT_FILE
    readme_path = agent_path / README_FILE

    if not config_path.exists():
        raise FileNotFoundError(f"Configuration file {CONFIG_FILE} not found in {agent_path}")

    config = json.dumps(json.loads(config_path.read_text()), indent=2)
    prompt = prompt_path.read_text() if prompt_path.exists() else None
    readme = readme_path.read_text() if readme_path.exists() else None
    return {
        "name": f"{agent_path.parent.name}/{agent_path.name}",
        "config": config,
        "readme": readme,
        "prompt": prompt,
    }


AGENTS = []
for namespace in folder.iterdir():
    if namespace.is_dir():
        for agent in namespace.iterdir():
            if agent.is_dir():
                try:
                    AGENTS.append(load_agent(agent))
                except Exception as e:
                    print(f"Skipping {agent.name}: {e}")
AGENTS.sort(key=lambda x: x["name"])

# Export as parquet file
with TemporaryDirectory() as tmpdir:
    tmp_path = Path(tmpdir) / "data.parquet"
    pd.DataFrame(AGENTS).to_parquet(tmp_path, index=False)
    upload_file(
        path_or_fileobj=tmp_path,
        path_in_repo="data.parquet",
        repo_id=DATASET_ID,
        repo_type="dataset",
        commit_message="Update summary for dataset-viewer",
    )

Wauplin added a commit to huggingface/huggingface.js that referenced this pull request Jul 7, 2025
Fix docs example after
huggingface/huggingface_hub#3166 /
#1556. Since release
[0.33.2](https://github.com/huggingface/huggingface_hub/releases/tag/v0.33.2)
`tiny-agents` config follow VSCode format. We made the change without a
proper deprecation warning as it's still experimental and we wanted to
harmonize with VSCode as quickly as possible (to avoid future
conflicts).

Related PRs:
- huggingface/hub-docs#1816
- huggingface/transformers#39245
- huggingface/huggingface_hub#3205
- #1599
mintyleaf pushed a commit to Swarmind/huggingface_hub that referenced this pull request Jul 11, 2025
)

* [Tiny-Agent] Fix headers handling + secrets management

* no whitespace in id

* switch to VSCode config file format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants