Skip to main content
Glama

get_project_fields

Retrieve available fields and their options from GitHub Projects V2 to understand project structure and configure custom fields for better organization.

Instructions

Get fields available in a GitHub Project V2, including options for SingleSelect fields.

Args:
    owner: The GitHub organization or user name
    project_number: The project number

Returns:
    A formatted string with field details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes
project_numberYes

Implementation Reference

  • The main MCP tool handler for 'get_project_fields', decorated with @mcp.tool() which also serves as registration. It calls the GitHub client helper and formats the output.
    @mcp.tool()
    async def get_project_fields(owner: str, project_number: int) -> str:
        """Get fields available in a GitHub Project V2, including options for SingleSelect fields.
    
        Args:
            owner: The GitHub organization or user name
            project_number: The project number
    
        Returns:
            A formatted string with field details.
        """
        try:
            # Use the new method that returns structured data
            fields_details = await github_client.get_project_fields_details(
                owner, project_number
            )
    
            if not fields_details:
                return f"No fields found for project #{project_number} in {owner}"
    
            result = f"Fields for project #{project_number} in {owner}:\n\n"
            for field_name, details in fields_details.items():
                result += f"- Name: {field_name}\n"
                result += f"  ID: {details['id']}\n"
                result += f"  Type: {details['type']}\n"
    
                # Show options if it's a SingleSelect field
                if details["type"] == "ProjectV2SingleSelectField" and details.get(
                    "options"
                ):
                    result += "  Options (Name: ID):\n"
                    for opt_name, opt_id in details["options"].items():
                        result += f"    - {opt_name}: {opt_id}\n"
    
                # TODO: Add similar display for Iteration fields if needed
    
                result += "\n"
    
            return result
        except GitHubClientError as e:
            logger.error(f"Error getting fields for project {owner}/{project_number}: {e}")
            return f"Error: Could not get fields for project {owner}/{project_number}. Details: {e}"
  • Supporting helper method in GitHubClient that performs the GraphQL query to fetch detailed project fields information, including options for single-select and iteration fields, and structures it into a dictionary.
    async def get_project_fields_details(
        self, owner: str, project_number: int
    ) -> Dict[str, Dict[str, Any]]:
        """
        Get fields for a GitHub Project V2, returning a structured dictionary.
        Args:
            owner: The GitHub organization or user name
            project_number: The project number
        Returns:
            Dictionary mapping field name to its details (id, type, options).
        Raises:
            GitHubClientError: If project or fields cannot be retrieved.
        """
        try:
            project_id = await self.get_project_node_id(owner, project_number)
        except GitHubClientError as e:
            logger.error(f"Cannot get fields details: {e}")
            raise
    
        query = """
        query GetProjectFields($projectId: ID!) {
          node(id: $projectId) {
            ... on ProjectV2 {
              fields(first: 50) {
                nodes {
                  ... on ProjectV2Field { id name __typename }
                  ... on ProjectV2IterationField {
                     id name __typename
                     configuration { iterations { id title startDate duration } }
                  }
                  ... on ProjectV2SingleSelectField {
                     id name __typename
                     options { id name color description }
                  }
                  # Add other field types if needed
                }
              }
            }
          }
        }
        """
        variables = {"projectId": project_id}
    
        try:
            result = await self.execute_query(query, variables)
            if not result.get("node") or not result["node"].get("fields"):
                raise GitHubClientError(
                    f"Could not retrieve fields for project {owner}/{project_number}"
                )
    
            fields_nodes = result["node"]["fields"]["nodes"]
            field_details_map: Dict[str, Dict[str, Any]] = {}
            for field in fields_nodes:
                field_name = field.get("name")
                if field_name:
                    options_map = {}
                    if field.get("options"):
                        options_map = {
                            opt["name"]: opt["id"] for opt in field["options"]
                        }
                    iterations_map = {}
                    if field.get(
                        "__typename"
                    ) == "ProjectV2IterationField" and field.get(
                        "configuration", {}
                    ).get(
                        "iterations"
                    ):
                        iterations = field.get("configuration", {}).get(
                            "iterations", []
                        )
                        iterations_map = {
                            iter["title"]: iter["id"] for iter in iterations
                        }
    
                    field_details_map[field_name] = {
                        "id": field.get("id"),
                        "type": field.get("__typename"),
                        "options": options_map,  # Map Name -> ID
                        "iterations": iterations_map,
                    }
            return field_details_map
        except GitHubClientError as e:
            logger.error(
                f"Failed to get fields details for project {owner}/{project_number}: {e}"
            )
            raise
        except Exception as e:  # Catch potential errors during processing
            logger.error(
                f"Unexpected error processing fields for project {owner}/{project_number}: {e}"
            )
            raise GitHubClientError(
                f"Could not process fields for project {owner}/{project_number}"
            )
  • The @mcp.tool() decorator registers the get_project_fields function as an MCP tool.
    @mcp.tool()
Behavior2/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 states the action is a 'Get' operation, implying read-only behavior, but doesn't clarify authentication needs, rate limits, error conditions, or what 'formatted string' entails. This is inadequate for a tool with zero annotation coverage.

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 appropriately sized and front-loaded, with the purpose stated first followed by parameter and return details in a structured format. Every sentence adds value, though minor improvements in flow could enhance readability.

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

Completeness3/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 (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers purpose and parameters but lacks details on behavioral traits, usage context, and output specifics, leaving gaps that could hinder effective agent use.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'owner' as 'The GitHub organization or user name' and 'project_number' as 'The project number', which clarifies beyond the schema's basic titles. However, it doesn't detail format constraints or examples, preventing a perfect score.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'fields available in a GitHub Project V2', with specific mention of SingleSelect fields. It distinguishes from siblings like get_project_items (which retrieves items, not fields) and update_project_item_field (which modifies fields). However, it doesn't explicitly contrast with all siblings, keeping it at 4 rather than 5.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites, context for usage, or comparisons to other field-related operations that might exist. This leaves the agent without explicit direction on application scenarios.

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/Arclio/github-projects-mcp'

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