Skip to main content
Glama
talhaorak

Taiga MCP Bridge

by talhaorak

get_project

Retrieve detailed project information by ID using the Taiga MCP Bridge, enabling AI systems to access and manage Taiga project management platform data efficiently.

Instructions

Gets detailed information about a specific project by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
session_idYes

Implementation Reference

  • The primary handler function for the 'get_project' MCP tool. It validates the session, retrieves the Taiga client, calls the projects.get API method, and handles exceptions appropriately.
    @mcp.tool("get_project", description="Gets detailed information about a specific project by its ID.")
    def get_project(session_id: str, project_id: int) -> Dict[str, Any]:
        """Retrieves project details by ID."""
        logger.info(
            f"Executing get_project ID {project_id} for session {session_id[:8]}...")
        taiga_client_wrapper = _get_authenticated_client(session_id) # Use wrapper variable name
        try:
            # Use pytaigaclient syntax: client.resource.get(project_id)
            project = taiga_client_wrapper.api.projects.get(project_id)
            # return project.to_dict() # Remove .to_dict()
            return project # Return directly
        except TaigaException as e:
            logger.error(
                f"Taiga API error getting project {project_id}: {e}", exc_info=False)
            raise e
        except Exception as e:
            logger.error(
                f"Unexpected error getting project {project_id}: {e}", exc_info=True)
            raise RuntimeError(f"Server error getting project: {e}")
  • Helper function used by get_project (and other tools) to retrieve and validate the authenticated TaigaClientWrapper instance from the active sessions store.
    def _get_authenticated_client(session_id: str) -> TaigaClientWrapper:
        """
        Retrieves the authenticated TaigaClientWrapper for a given session ID.
        Raises PermissionError if the session is invalid or not found.
        """
        client = active_sessions.get(session_id)
        # Also check if the client object itself exists and is authenticated
        if not client or not client.is_authenticated:
            logger.warning(f"Invalid or expired session ID provided: {session_id}")
            # Raise PermissionError - FastMCP will map this to an appropriate error response
            raise PermissionError(
                f"Invalid or expired session ID: '{session_id}'. Please login again.")
        logger.debug(f"Retrieved valid client for session ID: {session_id}")
        return client
  • The TaigaClientWrapper class provides the authenticated client instance used by get_project to interact with the Taiga API via pytaigaclient.
    class TaigaClientWrapper:
        """
        A wrapper around the pytaiga-client library to manage API instance
        and authentication state.
        """
    
        def __init__(self, host: str):
            if not host:
                raise ValueError("Taiga host URL cannot be empty.")
            # Store host, but initialize client later during login/token auth
            self.host = host
            # Use the new client type
            self.api: Optional[TaigaClient] = None
            logger.info(f"TaigaClientWrapper initialized for host: {self.host}")
    
        def login(self, username: str, password: str) -> bool:
            """
            Authenticates with the Taiga instance using username and password.
            Uses pytaigaclient.
            """
            try:
                logger.info(
                    f"Attempting login for user '{username}' on {self.host}")
                # Initialize the client here
                api_instance = TaigaClient(host=self.host)
                # Use the auth resource's login method
                api_instance.auth.login(username=username, password=password)
                self.api = api_instance
                logger.info(
                    f"Login successful for user '{username}'. Auth token acquired.")
                return True
            except TaigaException as e:
                logger.error(
                    f"Taiga login failed for user '{username}': {e}", exc_info=False)
                self.api = None
                raise e
            except Exception as e:
                logger.error(
                    f"An unexpected error occurred during login for user '{username}': {e}", exc_info=True)
                self.api = None
                # Wrap unexpected errors in TaigaException if needed, or re-raise
                raise TaigaException(f"Unexpected login error: {e}")
    
        # Add method for token authentication if needed by pytaigaclient
        # def set_token(self, token: str, token_type: str = "Bearer"):
        #     logger.info(f"Initializing TaigaClient with token on {self.host}")
        #     self.api = TaigaClient(host=self.host, auth_token=token, token_type=token_type)
        #     logger.info("TaigaClient initialized with token.")
    
        @property
        def is_authenticated(self) -> bool:
            """Checks if the client is currently authenticated (has an API instance with a token)."""
            # Check if api exists and has a token
            return self.api is not None and self.api.auth_token is not None
    
        def _ensure_authenticated(self):
            """Internal helper to check authentication before API calls."""
            if not self.is_authenticated:
                logger.error(
                    "Action required authentication, but client is not logged in.")
                # Use a standard exception type that FastMCP might handle better,
                # or a custom one if needed. PermissionError fits well.
                raise PermissionError(
                    "Client not authenticated. Please login first.")
    
    # No changes needed to _ensure_authenticated or is_authenticated property logic,
  • src/server.py:140-140 (registration)
    The @mcp.tool decorator registers the get_project function as an MCP tool with FastMCP.
    @mcp.tool("get_project", description="Gets detailed information about a specific project by its ID.")

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/talhaorak/pytaiga-mcp'

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