get_opportunity
Retrieve full details for a single youth opportunity by providing its ID. Access aggregated data on scholarships, fellowships, internships, conferences, and exchange programs.
Instructions
Get full details for a single opportunity by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/opportunity_mcp/server.py:57-60 (handler)The get_opportunity MCP tool handler function. Decorated with @mcp.tool(), takes an 'id' string parameter and returns an Opportunity or None. Delegates to _get_index().get(id).
@mcp.tool() def get_opportunity(id: str) -> Opportunity | None: """Get full details for a single opportunity by ID.""" return _get_index().get(id) - src/opportunity_mcp/index.py:201-205 (helper)The Index.get() method that performs the actual database lookup by SELECTing from the opportunities table WHERE id = ?. Returns an Opportunity object via _row_to_opportunity() or None if not found.
def get(self, opp_id: str) -> Opportunity | None: row = self.conn.execute( "SELECT * FROM opportunities WHERE id = ?", (opp_id,) ).fetchone() return _row_to_opportunity(row) if row else None - src/opportunity_mcp/schema.py:40-59 (schema)The Opportunity Pydantic model returned by get_opportunity. Defines all fields (id, title, type, summary, deadline, funded, etc.) with validation.
class Opportunity(BaseModel): """A single opportunity record. The shape every adapter must produce.""" model_config = ConfigDict(use_enum_values=False) id: str = Field(..., description="sha1(source + canonical_url)[:16]") title: str type: OpportunityType summary: str = Field(..., max_length=500) deadline: date | None = None funded: FundingLevel = FundingLevel.UNKNOWN eligible_countries: list[str] | Literal["worldwide"] | None = None eligible_levels: list[StudyLevel] = Field(default_factory=list) host_country: str | None = None apply_url: AnyHttpUrl source_site: str source_url: AnyHttpUrl posted_at: datetime scraped_at: datetime raw_categories: list[str] = Field(default_factory=list) - src/opportunity_mcp/server.py:28-28 (registration)The @mcp.tool() decorator on the same line as 'def get_opportunity' registers the function as a tool with the FastMCP server.
@mcp.tool()