Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

[BUG] Remote MCP auth issue? #318

@hemanth

Description

@hemanth

Description

Error connecting to remote MCP which needs auth.

Steps to Reproduce

from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import sys # Import sys to access exception information

server_params = {
    "url": "https://mcp.paypal.com/sse",
    "headers": {
        "Authorization": "Bearer <Token>",
    }
}

try:
    with MCPServerAdapter(server_params) as tools:
        print("Available MCP Tools:", [tool.name for tool in tools])

        doc_agent = Agent(
            role="PayPal API Expert",
            goal="Find answers to questions about PayPal products and APIs using the available MCP tool.",
            backstory="A helpful assistant for PayPal documentation and API references.",
            tools=tools,
            reasoning=True,
            reasoning_steps=2,
            memory=True,
            verbose=True
        )

        doc_task = Task(
            description="Find the answer to: {question} using the available MCP tools.",
            expected_output="A very detailed and accurate answer to the user's PayPal question.",
            output_file="output/doc_answer.md",
            agent=doc_agent,
            markdown=True
        )

        crew = Crew(
            agents=[doc_agent],
            tasks=[doc_task],
            verbose=True,
        )

        result = crew.kickoff(inputs={"question": input("PayPal docs, how may I help you? ") })
        print("\nFinal Output:\n", result)
except RuntimeError as e:
    # Catch the specific RuntimeError raised by MCPServerAdapter
    print(f"Caught a RuntimeError during MCPServerAdapter initialization: {e}", file=sys.stderr)
    # The original exception is the cause of this RuntimeError, which is the KeyError
    original_exception = e.__cause__
    if original_exception:
        print(f"Original exception was: {type(original_exception).__name__}: {original_exception}", file=sys.stderr)
    print("Please check the MCP server's schema or try updating the libraries.", file=sys.stderr)
except Exception as e:
    # Catch any other unexpected exceptions
    print(f"An unexpected error occurred: {type(e).__name__}: {e}", file=sys.stderr)

Expected behavior

Should connect and list the tools

Screenshots/Code snippets

/usr/local/lib/python3.11/dist-packages/pydantic/fields.py:1076: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'items', 'anyOf', 'enum', 'properties'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
  warn(
Caught a RuntimeError during MCPServerAdapter initialization: Failed to initialize MCP Adapter: '#/properties/subscriber/properties/name'
Original exception was: KeyError: '#/properties/subscriber/properties/name'
Please check the MCP server's schema or try updating the libraries.

Operating System

Ubuntu 20.04

Python Version

3.10

crewAI Version

0.46.0 (latest)

crewAI Tools Version

0.46.0

Virtual Environment

Venv

Evidence

/usr/local/lib/python3.11/dist-packages/pydantic/fields.py:1076: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'items', 'anyOf', 'enum', 'properties'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
  warn(
Caught a RuntimeError during MCPServerAdapter initialization: Failed to initialize MCP Adapter: '#/properties/subscriber/properties/name'
Original exception was: KeyError: '#/properties/subscriber/properties/name'
Please check the MCP server's schema or try updating the libraries.

Possible Solution

Provide auth via headers and regular browser oauth

Additional context

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions