list_accounts
Retrieve all accounts within a specified Octopus Deploy space. Filter results by name, account type, or other parameters to manage DevOps resources.
Instructions
List accounts in a space
This tool lists all accounts in a given space. The space name is required. You can optionally filter by various parameters like name, account type, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spaceName | Yes | ||
| skip | No | ||
| take | No | ||
| ids | No | ||
| partialName | No | ||
| accountType | No |
Implementation Reference
- src/tools/listAccounts.ts:30-70 (handler)The handler function for the 'list_accounts' tool. It creates an Octopus Deploy client, resolves the space ID, queries the accounts API with optional filters, maps the account resources, and returns a JSON-formatted text content response.async ({ spaceName, skip, take, ids, partialName, accountType, }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceId = await resolveSpaceId(client, spaceName); const response = await client.get<ResourceCollection<AccountResource>>( "~/api/{spaceId}/accounts{?skip,take,ids,partialName,accountType}", { spaceId, skip, take, ids, partialName, accountType, } ); const accounts = response.Items.map((account: AccountResource) => mapAccountResource(account)); return { content: [ { type: "text", text: JSON.stringify({ totalResults: response.TotalResults, itemsPerPage: response.ItemsPerPage, numberOfPages: response.NumberOfPages, lastPageNumber: response.LastPageNumber, items: accounts, }), }, ], }; }
- src/tools/listAccounts.ts:19-25 (schema)Zod input schema defining parameters for the list_accounts tool: spaceName (required), skip, take, ids, partialName, accountType (optional).spaceName: z.string(), skip: z.number().optional(), take: z.number().optional(), ids: z.array(z.string()).optional(), partialName: z.string().optional(), accountType: z.nativeEnum(AccountType).optional(), },
- src/tools/listAccounts.ts:74-78 (registration)Self-registration of the list_accounts tool definition into the TOOL_REGISTRY via registerToolDefinition, specifying toolset 'accounts' and readOnly: true.registerToolDefinition({ toolName: "list_accounts", config: { toolset: "accounts", readOnly: true }, registerFn: registerListAccountsTool, });
- src/tools/listAccounts.ts:12-72 (registration)The registerListAccountsTool function that calls server.tool to register the list_accounts tool with its description, input schema, output hints, and handler on the MCP server.export function registerListAccountsTool(server: McpServer) { server.tool( "list_accounts", `List accounts in a space This tool lists all accounts in a given space. The space name is required. You can optionally filter by various parameters like name, account type, etc.`, { spaceName: z.string(), skip: z.number().optional(), take: z.number().optional(), ids: z.array(z.string()).optional(), partialName: z.string().optional(), accountType: z.nativeEnum(AccountType).optional(), }, { title: "List all accounts in an Octopus Deploy space", readOnlyHint: true, }, async ({ spaceName, skip, take, ids, partialName, accountType, }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceId = await resolveSpaceId(client, spaceName); const response = await client.get<ResourceCollection<AccountResource>>( "~/api/{spaceId}/accounts{?skip,take,ids,partialName,accountType}", { spaceId, skip, take, ids, partialName, accountType, } ); const accounts = response.Items.map((account: AccountResource) => mapAccountResource(account)); return { content: [ { type: "text", text: JSON.stringify({ totalResults: response.TotalResults, itemsPerPage: response.ItemsPerPage, numberOfPages: response.NumberOfPages, lastPageNumber: response.LastPageNumber, items: accounts, }), }, ], }; } ); }