Creating an MCP client I got an error

Query: Hi

Error: “Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the X-Api-Key or Authorization headers to be explicitly omitted”

what is missing in my setup? I follow the lecture instructions but I got this error

Are you working in the course notebook, or are you installing the assignment on some other platform?

1 Like

Same problem here.
Apparently the issue is in this part:

        response = self.anthropic.messages.create(
            max_tokens=2024,
            model="claude-3-7-sonnet-20250219",
            tools=self.available_tools,  # tools exposed to the LLM
            messages=messages,
        )

I got the same problem. What I figured out is to create an Anthropic API key (pay $5), save ‘ANTHROPIC_API_KEY=’ in .env file, then load the environment variable in mcp_chatbot.py.