Skip to main content
Glama

search_opportunities

Search across all indexed opportunities using natural language. Filter by type, funding status, and deadline to locate relevant scholarships, fellowships, and more.

Instructions

Full-text search across all indexed opportunities.

Args: query: Natural-language search query (e.g. "fully funded master's scholarship Germany"). type: Optional filter by opportunity type (scholarship, fellowship, internship, conference, …). funded_only: If True, only return fully-funded opportunities. deadline_before: Only return opportunities with deadlines on or before this date (ISO YYYY-MM-DD). limit: Maximum number of results. Default 20.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
typeNo
funded_onlyNo
deadline_beforeNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'search_opportunities'. Decorated with @mcp.tool(), it delegates to Index.search().
    @mcp.tool()
    def search_opportunities(
        query: str,
        type: OpportunityType | None = None,
        funded_only: bool = False,
        deadline_before: date | None = None,
        limit: int = 20,
    ) -> list[Opportunity]:
        """Full-text search across all indexed opportunities.
    
        Args:
            query: Natural-language search query (e.g. "fully funded master's
                scholarship Germany").
            type: Optional filter by opportunity type
                (scholarship, fellowship, internship, conference, …).
            funded_only: If True, only return fully-funded opportunities.
            deadline_before: Only return opportunities with deadlines on or
                before this date (ISO YYYY-MM-DD).
            limit: Maximum number of results. Default 20.
        """
        return _get_index().search(
            query,
            opp_type=type,
            funded_only=funded_only,
            deadline_before=deadline_before,
            limit=limit,
        )
  • The @mcp.tool() decorator registers this function as an MCP tool named 'search_opportunities'.
    @mcp.tool()
  • The Opportunity Pydantic model used as the return type of search_opportunities.
    class Opportunity(BaseModel):
        """A single opportunity record. The shape every adapter must produce."""
  • The OpportunityType enum used as the 'type' parameter in search_opportunities.
    class OpportunityType(StrEnum):
        SCHOLARSHIP = "scholarship"
        FELLOWSHIP = "fellowship"
        INTERNSHIP = "internship"
        CONFERENCE = "conference"
        EXCHANGE = "exchange"
        COMPETITION = "competition"
        GRANT = "grant"
        AWARD = "award"
        OTHER = "other"
  • The Index.search() method that executes the FTS5 search with optional filters and returns parsed Opportunity objects.
    def search(
        self,
        query: str,
        *,
        opp_type: OpportunityType | None = None,
        funded_only: bool = False,
        deadline_before: date | None = None,
        limit: int = 20,
    ) -> list[Opportunity]:
        fts_query = _to_fts_query(query)
        if fts_query is None:
            # No usable tokens — fall through to a posted_at-ordered listing.
            return self.latest(opp_type=opp_type, limit=limit)
    
        sql = (
            "SELECT o.* FROM opportunities o "
            "JOIN opportunities_fts f ON f.rowid = o.rowid "
            "WHERE opportunities_fts MATCH ?"
        )
        params: list = [fts_query]
    
        if opp_type:
            sql += " AND o.type = ?"
            params.append(opp_type.value)
        if funded_only:
            sql += " AND o.funded = ?"
            params.append(FundingLevel.FULLY_FUNDED.value)
        if deadline_before:
            sql += " AND o.deadline IS NOT NULL AND o.deadline <= ?"
            params.append(deadline_before.isoformat())
    
        sql += " ORDER BY rank LIMIT ?"
        params.append(limit)
    
        rows = self.conn.execute(sql, params).fetchall()
        return [_row_to_opportunity(r) for r in rows]
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must disclose behavioral traits. It explains the search functionality and parameters effectively but does not mention pagination, ordering, potential rate limits, or authentication requirements. The output schema exists but is not referenced, so return value behavior is implied rather than stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose sentence followed by a numbered list of parameters. It is relatively concise but includes a slightly verbose example for 'query.' Each sentence adds value, though the example could be considered extraneous.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool complexity (5 parameters, search with filters) and the presence of an output schema, the description covers parameter semantics thoroughly. It does not explain edge cases or output structure, but the output schema mitigates this. Overall, it provides sufficient context for an agent to select and invoke the tool appropriately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description carries the full burden. It provides clear and meaningful explanations for all five parameters, including examples for 'query' and acceptable values for 'type' (e.g., 'scholarship, fellowship'), default values, and format for 'deadline_before' (ISO YYYY-MM-DD). This adds substantial context beyond the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Full-text search across all indexed opportunities,' which clearly identifies the verb (search) and resource (opportunities). It distinguishes itself from sibling tools like get_opportunity (single item retrieval) and list_latest (recent listings) by focusing on text-based search with filters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage context by giving example queries and explaining each parameter. However, it does not explicitly state when to use this tool over alternatives or when not to use it. No mention of exclusions or prerequisites is present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/revolutionarybukhari/opportunity-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server