AttributeError: module 'anthropic' has no attribute 'beta'
Problem
Hi , I am testing the Anthropic API / MCP integration in Python SDK. I received the error: "AttributeError: module 'anthropic' has no attribute 'beta' Have you run into this ? Any idea if the Python SDK is ready for beta messages API ? my code: [code block] Reference doc/example: https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector Anthropic SDK version: Version: 0.62.0 Anthropic SDK libraries / namespaces : `['AI_PROMPT', 'APIConnectionError', 'APIError', 'APIResponse', 'APIResponseValidationError', 'APIStatusError', 'APITimeoutError', 'Anthropic', 'AnthropicBedrock', 'AnthropicError', 'AnthropicVertex', 'AsyncAPIResponse', 'AsyncAnthropic', 'AsyncAnthropicBedrock', 'AsyncAnthropicVertex', 'AsyncClient', 'AsyncMessageStream', 'AsyncMessageStreamManager', 'AsyncStream', 'AuthenticationError', 'BadRequestError', 'BaseModel', 'BetaAsyncMessageStream', 'BetaAsyncMessageStreamManager', 'BetaContentBlockStopEvent', 'BetaInputJsonEvent', 'BetaMessageStopEvent', 'BetaMessageStream', 'BetaMessageStreamEvent', 'BetaMessageStreamManager', 'BetaTextEvent', 'Client', 'ConflictError', 'ContentBlockStopEvent', 'DEFAULT_CONNECTION_LIMITS', 'DEFAULT_MAX_RETRIES', 'DEFAULT_TIMEOUT', 'DefaultAioHttpClient', 'DefaultAsyncHttpxClient', 'DefaultHttpxClient', 'HUMAN_PROMPT', 'InputJsonEvent', 'InternalServerError', 'MessageStopEvent', 'MessageStream', 'MessageStreamEvent', 'MessageStreamManager', 'NOT_GIVEN', 'NoneType', 'NotFoundError', 'NotGiven', 'Omit', 'PermissionDeniedE
Error Output
error: "AttributeError: module 'anthropic' has no attribute 'beta'
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: AttributeError: module 'anthropic' has no attribute 'beta'
Hey! Our instructions on that docs page have a syntax error, which I'm working on fixing now! The actual code should be: [code block]
Trust Score
2 verifications
- 1
Hey! Our instructions on that docs page have a syntax error, which I'm working o
Hey! Our instructions on that docs page have a syntax error, which I'm working on fixing now! The actual code should be:
pythonimport anthropic client = anthropic.Anthropic() response = client.beta.messages.create( model="claude-sonnet-4-20250514", max_tokens=1000, messages=[{ "role": "user", "content": "What tools do you have available?" }], mcp_servers=[{ "type": "url", "url": "http://a.b.c.d/mcp", "name": "xyz01", }], betas=["mcp-client-2025-04-04"] ) print(response.content)
Validation
Resolved in anthropics/anthropic-sdk-python GitHub issue #1012. Community reactions: 1 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep