Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ UOS_MCP_PASSWORD="secret"
# Set to `true` to skip authentication and access only public content.
# UOS_MCP_SKIP_LOGIN="true"

# Custom User-Agent header sent to the university website.
# UOS_MCP_USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"

# If set, the server runs on HTTP transport instead of stdio.
# UOS_MCP_SERVER_PORT="8080"
# UOS_MCP_SERVER_HOST="127.0.0.1"
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,16 @@ The package can be configured using environment variables. You can either set th

### Environment Variables

| Variable | Description | Default |
|----------------------------------|----------------------------------------------------|----------------------------|
| `UOS_MCP_USERNAME` | Username of UOS account | `None` (required) |
| `UOS_MCP_PASSWORD` | Password of UOS account | `None` (required) |
| `UOS_MCP_SKIP_LOGIN` | Skip authentication (public content only) | `false` |
| `UOS_MCP_SERVER_HOST` | Host for HTTP transport | `127.0.0.1` |
| `UOS_MCP_SERVER_PORT` | Port for HTTP transport | `None` (enables HTTP mode) |
| `UOS_MCP_PEOPLE_DATA_PATH` | Data file for `uos_people_search` and the scraper | `./data/people.json` |
| `UOS_MCP_SCRAPE_DELAY_SECONDS` | Delay between requests in `mcp-uos-scrape-people` | `0.3` |
| Variable | Description | Default |
|----------------------------------|----------------------------------------------------|-------------------------------|
| `UOS_MCP_USERNAME` | Username of UOS account | `None` (required) |
| `UOS_MCP_PASSWORD` | Password of UOS account | `None` (required) |
| `UOS_MCP_SKIP_LOGIN` | Skip authentication (public content only) | `false` |
| `UOS_MCP_USER_AGENT` | User-Agent header sent to the university website | Mozilla/5.0 (Windows) string |
| `UOS_MCP_SERVER_HOST` | Host for HTTP transport | `127.0.0.1` |
| `UOS_MCP_SERVER_PORT` | Port for HTTP transport | `None` (enables HTTP mode) |
| `UOS_MCP_PEOPLE_DATA_PATH` | Data file for `uos_people_search` and the scraper | `./data/people.json` |
| `UOS_MCP_SCRAPE_DELAY_SECONDS` | Delay between requests in `mcp-uos-scrape-people` | `0.3` |

### Using a .env File

Expand Down
11 changes: 6 additions & 5 deletions mcpuos/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class UOSWebsiteClient:

BASE_URL = "https://www.uni-osnabrueck.de"

DEFAULT_HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
}
DEFAULT_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'

def __init__(self, username=None, password=None, base_url=None, skip_login=None):
def __init__(self, username=None, password=None, base_url=None, skip_login=None, user_agent=None):
"""
Initialize the UOSWebsiteClient.

Expand All @@ -42,15 +40,18 @@ def __init__(self, username=None, password=None, base_url=None, skip_login=None)
base_url: The base URL for the website. Defaults to BASE_URL.
skip_login: If True, skip authentication entirely (public content only).
If None, reads from UOS_MCP_SKIP_LOGIN env var. Defaults to False.
user_agent: The User-Agent header sent with requests. If None, reads from
UOS_MCP_USER_AGENT env var. Defaults to DEFAULT_USER_AGENT.
"""
self.username = username or os.getenv("UOS_MCP_USERNAME")
self.password = password or os.getenv("UOS_MCP_PASSWORD")
self.base_url = base_url or self.BASE_URL
if skip_login is None:
skip_login = os.getenv("UOS_MCP_SKIP_LOGIN", "").lower() in ("1", "true", "yes")
self.skip_login = skip_login
self.user_agent = user_agent or os.getenv("UOS_MCP_USER_AGENT", self.DEFAULT_USER_AGENT)
self.session = requests.Session()
self.session.headers.update(self.DEFAULT_HEADERS)
self.session.headers.update({'User-Agent': self.user_agent})
self._last_login = 0

def login(self):
Expand Down