How davieira/poliedro-gpt works
Purpose and Entry Points
Poliedro MCP is an unofficial Python bridge to the Poliedro P+ portal. It exposes student grades, assessments, messages, and calendar data through a REST/OpenAPI API for ChatGPT and MCP tools for Claude. Main service entry point: src/poliedro_mcp/api.py; local CLI/MCP entry points: src/poliedro_mcp/cli.py, src/poliedro_mcp/server.py.
API and Portal Integration
The REST layer serves /api/v1/*, OAuth endpoints, OpenAPI, privacy content, and health-oriented routes. It translates authenticated requests into Poliedro P+ API calls through shared client/service abstractions.
• src/poliedro_mcp/api.py
• src/poliedro_mcp/api_base.py
• src/poliedro_mcp/client.py
• src/poliedro_mcp/services.py
Poliedro Authentication and User Isolation
Users submit P+ credentials during OAuth/MCP login. The service validates them against Poliedro, obtains a temporary portal JWT, and keeps it associated with the current OAuth flow/session rather than a shared account. User context is the boundary preventing one user’s OAuth token from accessing another user’s P+ data.
• src/poliedro_mcp/auth.py
• src/poliedro_mcp/user_context.py
• src/poliedro_mcp/profile_discovery.py
ChatGPT OAuth Flow
ChatGPT Actions use conventional authorization-code OAuth: authorization/login UI, code exchange, and bearer-token access to REST resources. OAuth client configuration is environment-driven, with a configurable client ID and required signing secret.
• src/poliedro_mcp/oauth_proxy.py
• src/poliedro_mcp/oauth_config.py
• src/poliedro_mcp/auth.py
Remote Claude MCP Flow
The remote MCP endpoint provides Streamable HTTP tools plus OAuth authorization-server metadata and Dynamic Client Registration for Claude Custom Connectors. MCP OAuth tokens authenticate tool invocations; tools retrieve data through the same Poliedro service boundary as REST.
• src/poliedro_mcp/mcp_remote.py
• src/poliedro_mcp/mcp_auth_provider.py
• src/poliedro_mcp/mcp_oauth_tokens.py
• src/poliedro_mcp/mcp_tools.py
Local Claude Desktop Mode
Local MCP runs as a Python process and can obtain credentials from the host machine’s keychain via an interactive setup command. This is distinct from remote deployment: local configuration/credentials may exist on the user machine, while production is designed not to persist portal credentials.
• src/poliedro_mcp/server.py
• src/poliedro_mcp/setup_login.py
• src/poliedro_mcp/config_loader.py
Runtime and Deployment Boundaries
The runtime is Python (packaging in pyproject.toml, dependencies in requirements.txt) and is deployable as a container or Render service. Production requires OAUTH_CLIENT_SECRET and public API_BASE_URL; it depends externally on Poliedro P+ and on ChatGPT/Claude as OAuth or MCP clients.
• Dockerfile
• render.yaml
• docker-compose.yml
• runtime.txt
Main entry points: mcp_remote.py Remote MCP endpoint · services.py Portal services · api_base.py API resource layer · oauth_proxy.py ChatGPT OAuth flow
Components 21
Client Channels
- ChatGPT Actions
- Claude Custom Connector
- Claude Desktop
Application API
- REST and OpenAPI API · Serves /api/v1 resources, OpenAPI, privacy, and health routes.
src/poliedro_mcp/api.py - API resource layer
src/poliedro_mcp/api_base.py - Portal services · Maps authenticated requests to grades, assessments, messages, and calendar data.
src/poliedro_mcp/services.py - Poliedro client
src/poliedro_mcp/client.py - Remote MCP endpoint · Exposes tools plus OAuth metadata and dynamic client registration.
src/poliedro_mcp/mcp_remote.py - MCP tools
src/poliedro_mcp/mcp_tools.py
Authentication
- ChatGPT OAuth flow · Provides login, authorization-code exchange, and bearer-token handling.
src/poliedro_mcp/oauth_proxy.py - OAuth configuration · Uses client ID and signing secret configuration.
src/poliedro_mcp/oauth_config.py - Portal credential validation · Validates P+ credentials and obtains a temporary portal JWT.
src/poliedro_mcp/auth.py - Per-user context · Associates portal access with the current OAuth flow or session.
src/poliedro_mcp/user_context.py - Profile discovery
src/poliedro_mcp/profile_discovery.py - MCP token provider
src/poliedro_mcp/mcp_auth_provider.py - MCP OAuth tokens
src/poliedro_mcp/mcp_oauth_tokens.py
Local MCP
- Local MCP server
src/poliedro_mcp/server.py - Interactive local login · Obtains host-machine keychain credentials for local use.
src/poliedro_mcp/setup_login.py - Local config loader
src/poliedro_mcp/config_loader.py
Deployment
- Container / Render runtime · Production requires OAUTH_CLIENT_SECRET and public API_BASE_URL.
render.yaml
Other components
- Poliedro P+ portal
Connections 22
- ChatGPT Actions → ChatGPT OAuth flow: authorization code OAuth
- ChatGPT Actions → REST and OpenAPI API: bearer API requests
- ChatGPT OAuth flow → OAuth configuration: loads client settings
- ChatGPT OAuth flow → Portal credential validation: login credentials
- Portal credential validation → Profile discovery: validates identity
- Portal credential validation → Per-user context: stores portal JWT per flow
- REST and OpenAPI API → API resource layer: routes resources
- API resource layer → Per-user context: resolves user access
- API resource layer → Portal services: requests student data
- Portal services → Poliedro client: uses
- Poliedro client → Poliedro P+ portal: P+ API calls
- Claude Custom Connector → Remote MCP endpoint: Streamable HTTP MCP
- Remote MCP endpoint → MCP token provider: OAuth authorization
- MCP token provider → MCP OAuth tokens: issues and verifies tokens
- Remote MCP endpoint → MCP tools: tool invocations
- MCP tools → Portal services: shared data boundary
- Claude Desktop → Local MCP server: stdio MCP
- Interactive local login → Local config loader: writes local credential config
- Local MCP server → Local config loader: loads local credentials
- Local MCP server → Portal services: uses shared services
- Container / Render runtime → REST and OpenAPI API: hosts
- Container / Render runtime → Remote MCP endpoint: hosts