Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

list_organizations

Retrieve all Azure DevOps organizations available with current authentication to manage projects, work items, and repositories.

Instructions

List all Azure DevOps organizations accessible to the current authentication

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that authenticates with Azure DevOps (PAT or Azure Identity) and fetches the list of accessible organizations via VSSPS APIs.
    export async function listOrganizations(
      config: AzureDevOpsConfig,
    ): Promise<Organization[]> {
      try {
        // Determine auth method and create appropriate authorization header
        let authHeader: string;
    
        if (config.authMethod === AuthenticationMethod.PersonalAccessToken) {
          // PAT authentication
          if (!config.personalAccessToken) {
            throw new AzureDevOpsAuthenticationError(
              'Personal Access Token (PAT) is required when using PAT authentication',
            );
          }
          authHeader = createBasicAuthHeader(config.personalAccessToken);
        } else {
          // Azure Identity authentication (DefaultAzureCredential or AzureCliCredential)
          const credential =
            config.authMethod === AuthenticationMethod.AzureCli
              ? new AzureCliCredential()
              : new DefaultAzureCredential();
    
          const token = await credential.getToken(
            `${AZURE_DEVOPS_RESOURCE_ID}/.default`,
          );
    
          if (!token || !token.token) {
            throw new AzureDevOpsAuthenticationError(
              'Failed to acquire Azure Identity token',
            );
          }
    
          authHeader = `Bearer ${token.token}`;
        }
    
        // Step 1: Get the user profile to get the publicAlias
        const profileResponse = await axios.get(
          'https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=6.0',
          {
            headers: {
              Authorization: authHeader,
              'Content-Type': 'application/json',
            },
          },
        );
    
        // Extract the publicAlias
        const publicAlias = profileResponse.data.publicAlias;
        if (!publicAlias) {
          throw new AzureDevOpsAuthenticationError(
            'Unable to get user publicAlias from profile',
          );
        }
    
        // Step 2: Get organizations using the publicAlias
        const orgsResponse = await axios.get(
          `https://app.vssps.visualstudio.com/_apis/accounts?memberId=${publicAlias}&api-version=6.0`,
          {
            headers: {
              Authorization: authHeader,
              'Content-Type': 'application/json',
            },
          },
        );
    
        // Define the shape of the API response
        interface AzureDevOpsOrganization {
          accountId: string;
          accountName: string;
          accountUri: string;
        }
    
        // Transform the response
        return orgsResponse.data.value.map((org: AzureDevOpsOrganization) => ({
          id: org.accountId,
          name: org.accountName,
          url: org.accountUri,
        }));
      } catch (error) {
        // Handle profile API errors as authentication errors
        if (axios.isAxiosError(error) && error.config?.url?.includes('profile')) {
          throw new AzureDevOpsAuthenticationError(
            `Authentication failed: ${error.toJSON()}`,
          );
        } else if (
          error instanceof Error &&
          (error.message.includes('profile') ||
            error.message.includes('Unauthorized') ||
            error.message.includes('Authentication'))
        ) {
          throw new AzureDevOpsAuthenticationError(
            `Authentication failed: ${error.message}`,
          );
        }
    
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
    
        throw new AzureDevOpsAuthenticationError(
          `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Input schema for the list_organizations tool (empty object as no parameters are required).
    export const ListOrganizationsSchema = z.object({});
  • Tool definition registration including name, description, and input schema.
    export const organizationsTools: ToolDefinition[] = [
      {
        name: 'list_organizations',
        description:
          'List all Azure DevOps organizations accessible to the current authentication',
        inputSchema: zodToJsonSchema(ListOrganizationsSchema),
      },
    ];
  • MCP request dispatcher that constructs config from env vars and calls the core listOrganizations handler.
    case 'list_organizations': {
      // Use environment variables for authentication method and PAT
      // This matches how other features handle authentication
      const config: AzureDevOpsConfig = {
        authMethod:
          process.env.AZURE_DEVOPS_AUTH_METHOD?.toLowerCase() === 'pat'
            ? AuthenticationMethod.PersonalAccessToken
            : process.env.AZURE_DEVOPS_AUTH_METHOD?.toLowerCase() ===
                'azure-cli'
              ? AuthenticationMethod.AzureCli
              : AuthenticationMethod.AzureIdentity,
        personalAccessToken: process.env.AZURE_DEVOPS_PAT,
        organizationUrl: connection.serverUrl || '',
      };
    
      const result = await listOrganizations(config);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Request identifier function that checks if the tool name is 'list_organizations' for routing.
    export const isOrganizationsRequest: RequestIdentifier = (
      request: CallToolRequest,
    ): boolean => {
      const toolName = request.params.name;
      return ['list_organizations'].includes(toolName);
    };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions authentication scope but doesn't describe what 'list all' means operationally - whether it returns all organizations at once, uses pagination, what the output format is, or any rate limits. For a tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 a single, efficient sentence that communicates the essential information without any wasted words. It's front-loaded with the core functionality and appropriately sized for a simple listing tool.

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?

For a zero-parameter listing tool, the description covers the basic purpose adequately. However, with no annotations and no output schema, it should ideally provide more behavioral context about what 'list all' entails operationally. The authentication scope mention is helpful but insufficient for full completeness.

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 tool has 0 parameters with 100% schema description coverage, so the schema fully documents the parameter situation. The description appropriately doesn't waste space discussing non-existent parameters. A baseline of 4 is appropriate since there are no parameters to explain.

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 action ('List all') and resource ('Azure DevOps organizations'), making the purpose immediately understandable. However, it doesn't differentiate itself from other list tools in the sibling set (like list_projects, list_repositories, etc.) beyond specifying the resource type.

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?

The description provides minimal guidance - it mentions 'accessible to the current authentication' which gives some context about scope, but offers no explicit when-to-use advice, no alternatives for similar functionality, and no prerequisites beyond authentication. It doesn't help an agent decide when to choose this over other list tools.

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/Tiberriver256/mcp-server-azure-devops'

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