Skip to content

MCP server: get_attributes tool always fails for named attributes - TypeError: get_attribute() got an unexpected keyword argument 'timeout' #4542

Closed

Description

@SynthLuvr

Environment

  • OS: Linux (Ubuntu, x86_64)
  • SeleniumBase version: 4.54.13, and verified still present in the 4.56.5 wheel on PyPI
  • Python: 3.10
  • Browser: Google Chrome 152 (Pure CDP Mode)
  • Affected component: mcp_servers/server.py (SeleniumBase MCP server) + seleniumbase/core/sb_cdp.py

Summary

The get_attributes MCP tool always fails when a named attribute is requested — even when the MCP client omits timeout, because the server passes its own default (timeout=5) through to CDPMethods.get_attribute(), which does not accept a timeout parameter.

Repro

Via the MCP server (get_attributes with selector + attribute, e.g. attribute="href" on a link):

Error in get_attributes: TypeError - CDPMethods.get_attribute() got an unexpected keyword argument 'timeout'

Equivalent direct CDP Mode repro:

from seleniumbase import SB

with SB(uc=True, headless=True) as sb:
    sb.cdp.open_url("https://example.com")
    print(sb.cdp.get_attribute("h1", "innerText", timeout=5))
    # TypeError: CDPMethods.get_attribute() got an unexpected keyword argument 'timeout'

Root cause

mcp_servers/server.py, get_attributes tool (line 679 in 4.56.5; identical in 4.54.13):

if attribute:
    return sb.get_attribute(selector, attribute, timeout=timeout)

return sb.get_element_attributes(selector, timeout=timeout)

But seleniumbase/core/sb_cdp.py:

def get_attribute(self, selector, attribute):
    # line 1908 in 4.54.13 / 1934 in 4.56.5 — no `timeout` parameter

The all-attributes path works fine because get_element_attributes() does accept timeout.

Suggested fix

Drop the unsupported kwarg:

return sb.get_attribute(selector, attribute)

or preserve the documented timeout semantics by waiting for the element first:

if attribute:
    sb.find_element(selector, timeout=timeout)
    return sb.get_attribute(selector, attribute)

Happy to open a PR if helpful.

Activity

  1. self-assigned this
    on Nov 1, 2026
  2. added
    bugUh oh... Something needs to be fixed
    UC Mode / CDP ModeUndetected Chromedriver Mode and/or CDP Mode
    MCPRelated to the SeleniumBase MCP Server
    on Nov 1, 2026
  3. mdmintz commented on Nov 1, 2026

    @mdmintz
    Member

    Thanks for reporting this. Will be fixed in the next release.

    Note that your reproduction steps are incorrect. The MCP server uses Pure CDP Mode (sb_cdp).
    The proper code to reproduce the issue directly should look like this:

    from seleniumbase import sb_cdp
    
    sb = sb_cdp.Chrome()
    sb.goto("https://example.com")
    print(sb.get_attribute("p", "innerText", timeout=5))
  4. SynthLuvr commented on Nov 1, 2026

    @SynthLuvr
    Author

    Thanks @mdmintz for the quick response and the correction — you're right that sb_cdp.Chrome() is the canonical Pure CDP Mode entry point. I confirmed your form reproduces it exactly:

    from seleniumbase import sb_cdp
    
    sb = sb_cdp.Chrome(headless=True)
    sb.goto("https://example.com")
    print(sb.get_attribute("p", "innerText", timeout=5))
    # TypeError: CDPMethods.get_attribute() got an unexpected keyword argument 'timeout'

    (The signature mismatch is in CDPMethods.get_attribute() itself, so it reproduces from either entry point, but yours is the proper direct repro.) Looking forward to the next release — I'll validate the fix against it and report back.

  5. mdmintz commented on Nov 3, 2026

    @mdmintz
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

MCPRelated to the SeleniumBase MCP ServerUC Mode / CDP ModeUndetected Chromedriver Mode and/or CDP ModebugUh oh... Something needs to be fixed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions