This document is exclusively for AI Agent operational use. DO NOT include general development knowledge.
- This project,
@tiberriver256/mcp-server-azure-devops, is an MCP (Model Context Protocol) server. - Its primary function is to provide tools for interacting with Azure DevOps services.
- Core: TypeScript, Node.js
- Key Libraries:
@modelcontextprotocol/sdk: For MCP server and type definitions.azure-devops-node-api: For interacting with Azure DevOps.@azure/identity: For Azure authentication.zod: For schema definition and validation.zod-to-json-schema: For converting Zod schemas to JSON schemas for MCP tools.
- Testing: Jest (for unit, integration, and e2e tests).
- Linting/Formatting: ESLint, Prettier.
- Environment Management:
dotenv.
- Provides MCP tools to interact with Azure DevOps features including, but not limited to:
- Organizations
- Projects (list, get, get details)
- Repositories (list, get, get content, get tree)
- Work Items (list, get, create, update, manage links)
- Pull Requests (list, get, create, update, add/get comments)
- Pipelines (list, trigger)
- Search (code, wiki, work items)
- Users (get current user)
- Wikis (list, get page, create, update page)
./(Root):package.json: Project metadata, dependencies, and NPM scripts. REFER to this for available commands and dependencies.tsconfig.json: TypeScript compiler configuration. ADHERE to its settings..eslintrc.json: ESLint configuration for code linting. ADHERE to its rules.README.md: General project information.setup_env.sh: Shell script for environment setup.CHANGELOG.md(if present): Tracks changes between versions.
src/: Contains all TypeScript source code.src/features/: Core application logic. Each subdirectory represents a distinct Azure DevOps feature set (e.g.,projects,repositories).src/features/[feature-name]/: Contains all files related to a specific feature.src/features/[feature-name]/index.ts: Main export file for the feature. Exports request handlers (isFeatureRequest,handleFeatureRequest), tool definitions array (featureTools), schemas, types, and individual tool implementation functions. MODIFY this file when adding new tools or functionalities to the feature.src/features/[feature-name]/schemas.ts: Defines Zod input/output schemas for all tools within this feature. DEFINE new schemas here.src/features/[feature-name]/tool-definitions.ts: Defines MCP tools for the feature using@modelcontextprotocol/sdkandzodToJsonSchema. ADD new tool definitions here.src/features/[feature-name]/types.ts: Contains TypeScript type definitions specific to this feature. DEFINE feature-specific types here.src/features/[feature-name]/[tool-name]/: Subdirectory for a specific tool/action within the feature.src/features/[feature-name]/[tool-name]/feature.ts: Implements the core logic for the specific tool (e.g., API calls, data transformation). IMPLEMENT tool logic here.src/features/[feature-name]/[tool-name]/index.ts: Exports thefeature.tslogic and potentially tool-specific schemas/types if not in the parent feature files.src/features/[feature-name]/[tool-name]/schema.ts(optional, often re-exports from feature-levelschemas.ts): Defines or re-exports Zod schemas for this specific tool.
src/features/organizations/,src/features/pipelines/,src/features/projects/,src/features/pull-requests/,src/features/repositories/,src/features/search/,src/features/users/,src/features/wikis/,src/features/work-items/: Existing feature modules. REFER to these for patterns.
src/shared/: Contains shared modules and utilities used across features.src/shared/api/: Azure DevOps API client setup (e.g.,client.ts).src/shared/auth/: Authentication logic for Azure DevOps (e.g.,auth-factory.ts,client-factory.ts). USE these factories; DO NOT implement custom auth.src/shared/config/: Configuration management (e.g.,version.ts).src/shared/errors/: Shared error handling classes and utilities (e.g.,azure-devops-errors.ts,handle-request-error.ts). USE these for consistent error handling.src/shared/types/: Global TypeScript type definitions (e.g.,config.ts,request-handler.ts,tool-definition.ts).
src/utils/: General utility functions.src/utils/environment.ts: Provides default values for environment variables (e.g.,defaultProject,defaultOrg).
src/index.ts: Main application entry point. Handles environment variable loading and server initialization. Exports server components.src/server.ts: MCP server core logic. Initializes the server, registers all tool handlers from features, and sets up request routing. MODIFY this file to register new feature modules (theirisFeatureRequestandhandleFeatureRequesthandlers, andfeatureToolsarray).
docs/: Currently empty. If documentation is added, MAINTAIN it in sync with code changes.project-management/: Contains project planning and design documents. REFER toarchitecture-guide.mdfor high-level design.tests/: Directory for global test setup or utilities if any. Most tests are co-located with source files (e.g.,*.spec.unit.ts,*.spec.int.ts,*.spec.e2e.ts).
- Files and Directories: USE kebab-case (e.g.,
my-feature,get-project-details.ts). - Variables and Functions: USE camelCase (e.g.,
projectId,listProjects). - Classes, Interfaces, Enums, Types: USE PascalCase (e.g.,
AzureDevOpsClient,TeamProject,AuthenticationMethod). - Test Files:
- Unit tests:
[filename].spec.unit.ts(e.g.,get-project.spec.unit.ts). - Integration tests:
[filename].spec.int.ts(e.g.,get-project.spec.int.ts). - E2E tests:
[filename].spec.e2e.ts(e.g.,server.spec.e2e.ts).
- Unit tests:
- Feature Modules: Place under
src/features/[feature-name]/. - Tool Logic: Place in
src/features/[feature-name]/[tool-name]/feature.ts. - Schemas: Define in
src/features/[feature-name]/schemas.ts. - Tool Definitions (MCP): Define in
src/features/[feature-name]/tool-definitions.ts. - Types: Feature-specific types in
src/features/[feature-name]/types.ts; global types insrc/shared/types/.
- Prettier: Enforced via ESLint and lint-staged.
- Rule: ADHERE to formatting rules defined by Prettier (implicitly via
.eslintrc.jsonwhich extendsprettier). - Action: ALWAYS run
npm run format(or rely on lint-staged) before committing.
- ESLint: Configuration in
.eslintrc.json. - Rule: ADHERE to linting rules.
- Action: ALWAYS run
npm run lint(ornpm run lint:fix) and RESOLVE all errors/warnings before committing. - Key Lint Rules (from
.eslintrc.json):prettier/prettier: "error"(Prettier violations are ESLint errors).@typescript-eslint/no-explicit-any: "warn"(Avoidanywhere possible; it's "off" for*.spec.unit.tsandtests/**/*.ts).@typescript-eslint/no-unused-vars: ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }](No unused variables, allowing_prefix for ignored ones).
- TSDoc: USE TSDoc for documenting public functions, classes, interfaces, and types (e.g.,
/** ... */). - Inline Comments: For complex logic blocks, ADD inline comments (
// ...) explaining the purpose.
strict: true: ADHERE to strict mode.noImplicitAny: true: DO NOT use implicitany. Explicitly type all entities.noUnusedLocals: true,noUnusedParameters: true: ENSURE no unused local variables or parameters.moduleResolution: "Node16": Be aware of Node.js ESM module resolution specifics.paths: { "@/*": ["src/*"] }: USE path alias@/*for imports fromsrc/.
- Identify Feature: Determine the relevant feature directory in
src/features/[feature-name]/. - Create Tool Directory: Inside the feature directory, CREATE a new subdirectory for your tool, e.g.,
src/features/[feature-name]/[new-tool-name]/. - Implement Logic: CREATE
[new-tool-name]/feature.ts. Implement the core Azure DevOps interaction logic here.- USE
getClient()fromsrc/shared/api/client.tsorgetConnection()fromsrc/server.tsto getWebApi. - USE error handling from
src/shared/errors/.
- USE
- Define Schema:
- ADD Zod schema for the tool's input to
src/features/[feature-name]/schemas.ts. - EXPORT it.
- If needed, CREATE
[new-tool-name]/schema.tsand re-export the specific schema from the feature-levelschemas.ts.
- ADD Zod schema for the tool's input to
- Define MCP Tool:
- ADD tool definition to
src/features/[feature-name]/tool-definitions.ts. - Import the Zod schema and use
zodToJsonSchemaforinputSchema. - Ensure
namematches the intended tool name for MCP.
- ADD tool definition to
- Update Feature Index:
- In
src/features/[feature-name]/index.ts:- EXPORT your new tool's logic function (from
[new-tool-name]/feature.tsor itsindex.ts). - ADD your new tool's name to the
includes()check inisFeatureRequestfunction. - ADD a
casefor your new tool in thehandleFeatureRequestfunction to call your logic. Parse arguments using the Zod schema.
- EXPORT your new tool's logic function (from
- In
- Update Server: No changes usually needed in
src/server.tsif the feature module is already registered. The feature'stool-definitions.tsandhandleFeatureRequestwill be picked up. - Add Tests: CREATE
[new-tool-name]/feature.spec.unit.tsand[new-tool-name]/feature.spec.int.ts.
- Create Feature Directory: CREATE
src/features/[new-feature-module-name]/. - Implement Tools: Follow "Adding a New Tool" steps above for each tool within this new feature module. This includes creating
schemas.ts,tool-definitions.ts,types.ts(if needed), and subdirectories for each tool'sfeature.ts. - Create Feature Index: CREATE
src/features/[new-feature-module-name]/index.ts.- EXPORT all schemas, types, tool logic functions.
- EXPORT the
[new-feature-module-name]Toolsarray fromtool-definitions.ts. - CREATE and EXPORT
is[NewFeatureModuleName]Request(e.g.,isMyNewFeatureRequest) type guard. - CREATE and EXPORT
handle[NewFeatureModuleName]Request(e.g.,handleMyNewFeatureRequest) request handler function.
- Register Feature in Server:
- In
src/server.ts:- IMPORT
[new-feature-module-name]Tools,is[NewFeatureModuleName]Request, andhandle[NewFeatureModuleName]Requestfrom your new feature'sindex.ts. - ADD
...[new-feature-module-name]Toolsto thetoolsarray in theListToolsRequestSchemahandler. - ADD an
if (is[NewFeatureModuleName]Request(request)) { return await handle[NewFeatureModuleName]Request(connection, request); }block in theCallToolRequestSchemahandler.
- IMPORT
- In
- Add Tests: Ensure comprehensive tests for the new feature module.
@modelcontextprotocol/sdk:- USE
Serverclass from@modelcontextprotocol/sdk/server/index.jsto create the MCP server (src/server.ts). - USE
StdioServerTransportfor transport (src/index.ts). - USE schema types like
CallToolRequestSchemafrom@modelcontextprotocol/sdk/types.js. - DEFINE tools as
ToolDefinition[](seesrc/shared/types/tool-definition.tsand featuretool-definitions.tsfiles).
- USE
azure-devops-node-api:- This is the primary library for Azure DevOps interactions.
- OBTAIN
WebApiconnection object viagetConnection()fromsrc/server.tsorAzureDevOpsClientfromsrc/shared/auth/client-factory.ts. - USE specific APIs from the connection (e.g.,
connection.getCoreApi(),connection.getWorkItemTrackingApi()).
@azure/identity:- Used for Azure authentication (e.g.,
DefaultAzureCredential). - Primarily abstracted via
AzureDevOpsClientinsrc/shared/auth/. PREFER using this abstraction.
- Used for Azure authentication (e.g.,
zod:- USE for all input/output schema definition and validation.
- DEFINE schemas in
src/features/[feature-name]/schemas.ts. - USE
z.object({...}),z.string(),z.boolean(), etc. - USE
.optional(),.default(),.describe()for schema fields.
zod-to-json-schema:- USE to convert Zod schemas to JSON schemas for MCP
inputSchemaintool-definitions.ts.
- USE to convert Zod schemas to JSON schemas for MCP
dotenv:- Used in
src/index.tsto load environment variables from a.envfile.
- Used in
- Jest:
- Test files co-located with source files or in feature-specific
__test__directories. - Configuration in
jest.unit.config.js,jest.int.config.js,jest.e2e.config.js.
- Test files co-located with source files or in feature-specific
- ESLint/Prettier: See "Code Standards".
- Branch: CREATE or CHECKOUT a feature/bugfix branch from
main(or relevant development branch). - Implement: WRITE code and corresponding tests.
- Test:
- RUN unit tests:
npm run test:unit. - RUN integration tests:
npm run test:int. - RUN E2E tests:
npm run test:e2e. - Or run all tests:
npm test. - ENSURE all tests pass.
- RUN unit tests:
- Lint & Format:
- RUN
npm run lint(ornpm run lint:fix). RESOLVE all issues. - RUN
npm run format.
- RUN
- Commit:
- USE Conventional Commits specification (e.g.,
feat: ...,fix: ...). - RECOMMENDED: Use
npm run commit(usescz-conventional-changelog) for guided commit messages.
- USE Conventional Commits specification (e.g.,
- Pull Request: PUSH branch and CREATE Pull Request against
main(or relevant development branch).
build:tsc(Compiles TypeScript todist/).dev:ts-node-dev --respawn --transpile-only src/index.ts(Runs server in development with auto-restart).start:node dist/index.js(Runs compiled server).inspector:npm run build && npx @modelcontextprotocol/inspector node dist/index.js(Runs server with MCP Inspector).test:unit,test:int,test:e2e,test: Run respective test suites.lint,lint:fix: Run ESLint.format: Run Prettier.prepare:husky install(Sets up Git hooks).commit:cz(Interactive commitizen).
- No explicit CI/CD pipeline configuration files (e.g.,
azure-pipelines.yml,.github/workflows/) were found in the file listing. If added, REFER to them.
- Adding/Modifying a Tool:
- TOUCH
src/features/[feature-name]/[tool-name]/feature.ts(logic). - TOUCH
src/features/[feature-name]/schemas.ts(Zod schema). - TOUCH
src/features/[feature-name]/tool-definitions.ts(MCP tool definition). - TOUCH
src/features/[feature-name]/index.ts(export logic, update request handler and guard). - TOUCH corresponding
*.spec.unit.tsand*.spec.int.tsfiles.
- TOUCH
- Adding a New Feature Module:
- CREATE files within
src/features/[new-feature-module-name]/as per "Functionality Implementation Standards". - MODIFY
src/server.tsto import and register the new feature module's tools and handlers.
- CREATE files within
- Configuration Changes:
- Environment variables: Managed via
.envfile (loaded bydotenvinsrc/index.ts). - TypeScript config:
tsconfig.json. - Linting config:
.eslintrc.json.
- Environment variables: Managed via
- Dependency Management:
- MODIFY
package.jsonto add/update dependencies. - RUN
npm installornpm ci.
- MODIFY
- Documentation:
docs/directory is currently empty. If project documentation is added (e.g.,docs/feature-x.md), UPDATE it when the corresponding featuresrc/features/feature-x/is modified.README.md: UPDATE for significant high-level changes.
- Goal: To expose a new Azure DevOps API endpoint as an MCP tool.
- Decision: New or Existing Feature?
- IF the API relates to an existing service area (e.g., adding a new work item query type to
work-itemsfeature), MODIFY the existing feature module. - ELSE (e.g., interacting with Azure DevOps Audit Logs, a new service area), CREATE a new feature module. (See "Functionality Implementation Standards").
- IF the API relates to an existing service area (e.g., adding a new work item query type to
- Pattern Adherence:
- FOLLOW the established pattern:
src/features/[feature]/[tool]/feature.tsfor logic.src/features/[feature]/schemas.tsfor Zod schemas.src/features/[feature]/tool-definitions.tsfor MCP tool definitions.src/features/[feature]/index.tsfor feature-level exports, request guard (isFeatureRequest), and request handler (handleFeatureRequest).
- Example: To add
get_pipeline_run_logstopipelinesfeature:- CREATE
src/features/pipelines/get-pipeline-run-logs/feature.ts. - ADD
GetPipelineRunLogsSchematosrc/features/pipelines/schemas.ts. - ADD
get_pipeline_run_logsdefinition tosrc/features/pipelines/tool-definitions.ts. - UPDATE
src/features/pipelines/index.tsto export the new function, add toisPipelinesRequest, and handle inhandlePipelinesRequest.
- CREATE
- FOLLOW the established pattern:
- Error Handling:
- ALWAYS use custom error classes from
src/shared/errors/azure-devops-errors.ts(e.g.,AzureDevOpsResourceNotFoundError). - WRAP external API calls in try/catch blocks.
- USE
handleResponseErrorfromsrc/shared/errors/handle-request-error.tsin the top-level request handler insrc/server.ts(already done for existing features). Feature-specific handlers should re-throw custom errors.
- ALWAYS use custom error classes from
- Testing:
- ALWAYS write unit tests for the new logic in
[tool-name]/feature.spec.unit.ts. - ALWAYS write integration tests (NEVER mocking anything) in
[tool-name]/feature.spec.int.ts. Prefer integration tests over unit tests.
- ALWAYS write unit tests for the new logic in
- Identify Impact: DETERMINE all files affected by the change (logic, schemas, tool definitions, tests, potentially documentation).
- Maintain Consistency: ENSURE changes are consistent with existing patterns within that feature module.
- Update Tests: MODIFY existing tests or ADD new ones to cover the changes. ENSURE all tests pass.
- Version Bumping: For significant changes, consider if a version bump in
package.jsonis warranted (usually handled byrelease-please).
- DO NOT include general development knowledge or LLM-known facts in this
shrimp-rules.mddocument. This document is for project-specific operational rules for AI. - DO NOT explain project functionality in terms of what it does for an end-user. Focus on how to modify or add to it for an AI developer.
- DO NOT use
anytype implicitly.tsconfig.jsonenforcesnoImplicitAny: true..eslintrc.jsonwarns on explicitany(@typescript-eslint/no-explicit-any: "warn"), except in unit tests. MINIMIZE explicitany. - DO NOT bypass linting (
npm run lint) or formatting (npm run format) checks. Code MUST adhere to these standards. - DO NOT commit code that fails tests (
npm test). - DO NOT implement custom Azure DevOps authentication logic. USE the provided
AzureDevOpsClientfromsrc/shared/auth/. - DO NOT hardcode configuration values (like PATs, Org URLs, Project IDs). These should come from environment variables (see
src/index.tsgetConfigandsrc/utils/environment.ts). - DO NOT directly call Azure DevOps REST APIs if a corresponding function already exists in the
azure-devops-node-apilibrary or in shared project code (e.g.,src/shared/api/). - DO NOT modify files in
dist/directory directly. This directory is auto-generated bynpm run build. - DO NOT ignore the
project-management/directory for understanding architectural guidelines, but DO NOT replicate its content here. - DO NOT use mocks within integration tests.