session_identity
Browser identity (cookies, User-Agent) sent with Google Scholar requests.
Scholar answers plain HTTP clients with a JavaScript bot check. A real browser
passes it once and keeps the resulting cookies. Passing those cookies (and the
matching User-Agent) from the user’s own browser lets scholarly reuse that
verified session. This is experimental: the cookies expire and are typically
tied to the IP address and User-Agent they were issued for.
Cookie values are credentials. They are never logged or printed here, and
Config hides them from repr. Only cookie names are ever shown.
- google_scholar_search_mcp.session_identity.parse_cookies(text)[source]
Parse copied cookies into a name -> value mapping.
Accepts a
Cookieheader (a=1; b=2, optional leadingCookie:, possibly wrapped over several lines) or the tab-separated table copied from the browser’s Application/Storage tab (one cookie per line, name first, value second).
- google_scholar_search_mcp.session_identity.default_cookie_file()[source]
Where
set-cookiessaves the identity and the server looks for it.- Returns:
Path –
$XDG_CONFIG_HOME/google-scholar-mcp/cookies(~/.configwhen the variable is unset). The file need not exist.- Return type:
- google_scholar_search_mcp.session_identity.split_identity(text)[source]
Split the contents of a cookie file into cookies and User-Agent.
A cookie file may carry the browser’s User-Agent on a line of its own (
User-Agent: Mozilla/5.0 ...), asset-cookieswrites it, so one file describes the whole identity.
- google_scholar_search_mcp.session_identity.write_identity_file(path, cookies, user_agent)[source]
Save cookies and User-Agent to a file only the owner can read.
- google_scholar_search_mcp.session_identity.login_cookie_names(cookies)[source]
Return the names of any Google login cookies in a cookie set.
- google_scholar_search_mcp.session_identity.set_identity(cookies, user_agent)[source]
Configure the identity used for all following Scholar requests.
- google_scholar_search_mcp.session_identity.current_cookie_names()[source]
Names of the configured cookies (for diagnostics; never the values).
- google_scholar_search_mcp.session_identity.apply_identity(request)[source]
Add the configured cookies and User-Agent to a Scholar request.
Cookies already on the request (from the client’s own jar, e.g. refreshed by Scholar’s
Set-Cookie) win over the configured ones of the same name. Requests to other hosts are left alone.- Parameters:
request (httpx.Request) – Request about to be sent; modified in place.