Skip to main content
Glama
singlestore-labs

SingleStore MCP Server

set_organization

Set the organization for all subsequent API calls in SingleStore MCP Server. Use this after logging in to select the target organization by ID or name, ensuring all API requests align with the chosen organization.

Instructions

Select which SingleStore organization to use for all subsequent API calls.

This tool must be called after logging in and before making other API requests.
Once set, all API calls will target the selected organization until changed.

Args:
    orgID: Name or ID of the organization to select

Returns:
    Dictionary with the selected organization ID and name

Usage:
- Call get_organizations first to see available options
- Then call this tool with either the organization's name or ID
- All subsequent API calls will use the selected organization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ctxNo
orgIDYes

Implementation Reference

  • The main handler function for the 'set_organization' tool. It validates the provided organization_id against available organizations, sets it in the config settings, and returns success or error details.
    async def set_organization(ctx: Context, organization_id: str) -> dict:
        """
        Set the current organization after retrieving the list from choose_organization.
        This tool should only be used when the client doesn't support elicitation.
    
        Args:
            organization_id: The ID of the organization to select, as obtained from the
                           choose_organization tool's response.
    
        Returns:
            Dictionary with selected organization details
    
        Important:
        - This tool should only be called after choose_organization returns a 'pending_selection' status
        - The organization_id must be one of the IDs returned by choose_organization
    
        Example flow:
        1. Call choose_organization first
        2. If it returns 'pending_selection', get the organization ID from the list
        3. Call set_organization with the chosen ID
        """
        settings = config.get_settings()
        user_id = config.get_user_id()
        # Track tool call event
        settings.analytics_manager.track_event(
            user_id,
            "tool_calling",
            {"name": "set_organization", "organization_id": organization_id},
        )
    
        logger.debug(f"Setting organization ID: {organization_id}")
    
        try:
            # Get the list of organizations to validate the selection
            organizations = query_graphql_organizations()
    
            # Find the selected organization
            selected_org = next(
                (org for org in organizations if org["orgID"] == organization_id), None
            )
    
            if not selected_org:
                available_orgs = ", ".join(org["orgID"] for org in organizations)
                return {
                    "status": "error",
                    "message": f"Organization ID '{organization_id}' not found. Available IDs: {available_orgs}",
                    "errorCode": "INVALID_ORGANIZATION",
                    "errorDetails": {
                        "provided_id": organization_id,
                        "available_ids": [org["orgID"] for org in organizations],
                    },
                }
    
            # Set the selected organization in settings
            if hasattr(settings, "org_id"):
                settings.org_id = selected_org["orgID"]
            else:
                setattr(settings, "org_id", selected_org["orgID"])
    
            await ctx.info(
                f"Organization set to: {selected_org['name']} (ID: {selected_org['orgID']})"
            )
    
            return {
                "status": "success",
                "message": f"Successfully set organization to: {selected_org['name']} (ID: {selected_org['orgID']})",
                "data": {
                    "organization": selected_org,
                },
                "metadata": {
                    "timestamp": datetime.now(timezone.utc).isoformat(),
                    "user_id": user_id,
                },
            }
    
        except Exception as e:
            logger.error(f"Error setting organization: {str(e)}")
            return {
                "status": "error",
                "message": f"Failed to set organization: {str(e)}",
                "errorCode": "ORGANIZATION_SET_FAILED",
                "errorDetails": {"exception_type": type(e).__name__},
            }
  • Import of the set_organization function and its inclusion in the central tools_definition list used for creating and registering MCP tools.
    from src.api.tools.organization import (
        organization_info,
        choose_organization,
        set_organization,
    )
    
    # Define the tools with their metadata
    tools_definition = [
        {"func": get_user_info},
        {"func": organization_info},
        {"func": choose_organization},
        {"func": set_organization},
  • Registration logic in the tool registry that conditionally skips registering set_organization when using API key authentication in local mode.
    # List of tools to exclude when using API key authentication
    api_key_excluded_tools = ["choose_organization", "set_organization"]
    
    for tool in filtered_tools:
        func = tool.func
        # Skip organization-related tools when using API key authentication
        if using_api_key and func.__name__ in api_key_excluded_tools:
            continue
        mcp.tool(name=func.__name__, description=func.__doc__)(func)
  • Re-export of the set_organization function from the organization module for convenient import in tools.py.
    from .organization import organization_info, choose_organization, set_organization
    
    __all__ = ["organization_info", "choose_organization", "set_organization"]
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the tool sets a persistent context ('all subsequent API calls will target the selected organization until changed'), requires prior authentication ('after logging in'), and has a specific effect on the session. It doesn't mention error handling, rate limits, or permissions, but covers the core mutation behavior adequately for a context-setting tool.

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

Conciseness5/5

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

The description is well-structured and front-loaded: the first sentence states the purpose, followed by prerequisites, behavioral context, and a clear usage section with bullet points. Every sentence adds value—no repetition or fluff—and the bullet points enhance readability without wasting space.

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's moderate complexity (sets persistent context), no annotations, no output schema, and low schema coverage, the description is mostly complete. It covers purpose, usage, parameters, and behavioral impact. However, it lacks details on error cases (e.g., invalid orgID) and doesn't fully document the return value ('Dictionary with the selected organization ID and name' is vague without an output schema).

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

Parameters4/5

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

The input schema has 0% description coverage (only titles), so the description must compensate. It adds meaningful semantics: 'orgID: Name or ID of the organization to select' clarifies the parameter accepts either identifier type. However, it doesn't detail format constraints (e.g., string patterns) or provide examples, leaving some ambiguity. Given the low schema coverage, this is above baseline but not exhaustive.

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 clearly states the tool's purpose: 'Select which SingleStore organization to use for all subsequent API calls.' It specifies the verb ('select'), resource ('organization'), and scope ('all subsequent API calls'), distinguishing it from sibling tools like get_organizations (which lists organizations) or organization_info (which provides details).

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: 'This tool must be called after logging in and before making other API requests' (prerequisites), 'Call get_organizations first to see available options' (dependency), and 'All subsequent API calls will use the selected organization' (effect). It clearly indicates when to use it (after login, before other calls) and references the sibling tool get_organizations as an alternative for discovery.

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

Related 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/singlestore-labs/mcp-server-singlestore'

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