Local TFS MCP service for Windows development machines.
This repository is prepared for public collaboration with:
- CI workflow (
.github/workflows/ci.yml) - Dependabot updates (
.github/dependabot.yml) - Issue templates (
.github/ISSUE_TEMPLATE/*) - Pull request template (
.github/PULL_REQUEST_TEMPLATE.md) - Governance docs (
LICENSE,CONTRIBUTING.md,SECURITY.md,CODE_OF_CONDUCT.md)
GitHub About recommendations:
- Description:
Local TFVC MCP server for Windows automation workflows - Website: repository URL or project docs URL
- Topics:
mcp,tfvc,tfs,windows,python,automation
- Target platform: Windows (TFVC +
tf.exe+ PowerShell scripts). - Transport: MCP Streamable HTTP (
/mcp). - This project is designed for TFVC-style agent workflows (sessions, shelvesets, check-in flow).
pip install -e .[dev]Default scripts are in scripts/ and use the Conda env mcp_tfs_env.
Create/update env and install all dependencies:
.\scripts\Install-TfsMcp.ps1Create/update env, install dependencies, install service and start it:
.\scripts\Install-TfsMcp.ps1 -InstallWindowsService -StartWindowsServiceRun MCP in console/script mode:
.\scripts\Manage-TfsMcp.ps1 -Command runManage Windows service:
.\scripts\Manage-TfsMcp.ps1 -Command service-install
.\scripts\Manage-TfsMcp.ps1 -Command service-start
.\scripts\Manage-TfsMcp.ps1 -Command service-status
.\scripts\Manage-TfsMcp.ps1 -Command service-stop
.\scripts\Manage-TfsMcp.ps1 -Command service-uninstallRun in user background mode (no Windows service):
.\scripts\Manage-TfsMcp.ps1 -Command background-start
.\scripts\Manage-TfsMcp.ps1 -Command background-status
.\scripts\Manage-TfsMcp.ps1 -Command background-stopEnable auto-start at user logon (Startup folder shortcut):
.\scripts\Manage-TfsMcp.ps1 -Command startup-enable
.\scripts\Manage-TfsMcp.ps1 -Command startup-status
.\scripts\Manage-TfsMcp.ps1 -Command startup-disableOne-shot setup for Conda + Startup shortcut:
.\scripts\Setup-TfsMcpStartup.ps1One-shot setup and start MCP in background now:
.\scripts\Setup-TfsMcpStartup.ps1 -StartBackgroundNowpython -m pytest -qpython -m tfsmcp.service install
python -m tfsmcp.service start
python -m tfsmcp.service statuspython -m tfsmcp.service stop
python -m tfsmcp.service uninstallIf a TFS command returns an unauthorized error, the service runs every *.ps1 script inside C:\tfs_scripts in alphabetical order and retries the original command once.
- Detect the project with
tfs_detect_project. - Get guidance with
tfs_onboard_project. - Create isolated work with
tfs_session_create. - Materialize files when needed with
tfs_session_materialize(or setperform_get=trueon create). - Checkout files before editing.
- Use shelvesets for checkpoints.
This MCP does not clone a Git worktree. It creates a TFVC workspace/session pair that behaves like an isolated worktree for agents.
Direct onboarding flow:
- Call
tfs_detect_project(path). - If
kind == tfs_mapped, calltfs_onboard_project(path)and followrecommended_workflow. - Create an isolated session with
tfs_session_create(name, source_path, session_path). - For long-running setups, prefer
tfs_session_create_async(...)and polltfs_session_create_job_status(job_id). - Materialize session content explicitly with
tfs_session_materialize(name=...)when needed. - Perform edits only after
tfs_checkout(file). - Use
tfs_session_suspend(name)to checkpoint using shelveset. - Use
tfs_session_resume(name)to reactivate suspended session. - Use
tfs_session_promote(name, comment)when ready to promote. - Use
tfs_session_discard(name)to remove workspace and mark session discarded.
How TFVC is used under the hood in simulated worktree mode:
tfs_session_createrunstf workspace /new <name>.- It maps server path to local session path using
tf workfold /map. - It optionally materializes files with
tf get <session_path> /recursivewhenperform_get=trueor when envTFSMCP_SESSION_CREATE_AUTO_GET=true. tfs_session_materializecan runtf getlater as a separate step.tfs_session_suspendcreates a shelveset (currently named with workspace/session name).tfs_session_resumecurrently runs atf getrefresh in that workspace.tfs_session_promotecurrently performstf checkinscoped by workspace.tfs_session_discarddeletes workspace viatf workspace /delete.
Unauthorized recovery behavior:
- On unauthorized failures, scripts in
C:\tfs_scriptsare executed in alphabetical order. - After scripts complete successfully, the original TF command is retried once.
- This retry path is intended for interactive re-auth scripts when running in user/background mode.
Current limitations of simulated worktree mode:
- Resume does not perform real unshelve conflict resolution yet; it is currently a workspace refresh (
tf get). - Promote uses direct workspace checkin and not a full policy-rich promotion flow.
- Mapping validation/conflict recovery is basic and not yet exhaustive.
- Session state is local JSON state and not a distributed lock/coordination mechanism.
- Windows Service mode cannot open interactive auth UI; for interactive auth use background/user mode.
MCP transport:
- Streamable HTTP endpoint:
http://127.0.0.1:39393/mcp
This service is MCP-only now. Legacy REST endpoints (/health, /checkout, /sessions, etc.) are intentionally not exposed.
MCP tools:
tfs_detect_project(path)detects if path is TFVC-mapped and returns mapping metadata.tfs_onboard_project(path)returns recommended TFVC workflow guidance.tfs_checkout(filepath)checks out an existing file in TFVC.tfs_add(filepath, recursive=false)adds a new file/folder to source control.tfs_undo(filepath)undoes pending changes for a file/path.tfs_status(path, recursive=true, workspace=null)returns pending changes/status.tfs_get_latest(path, recursive=true, workspace=null)runstf getto sync latest.tfs_shelveset_list(owner=null, name_pattern=null)lists available shelvesets.tfs_unshelve(name, workspace=null)applies a shelveset into a workspace.tfs_session_create(name, source_path, session_path, perform_get=false)creates a TFS-backed session workspace and stores an active session record.tfs_session_create_from_path(name, source_path, session_path, perform_get=false)auto-resolves local path to server path before creating session.tfs_session_create_async(name, source_path, session_path, perform_get=false)starts session creation in background and returns ajob_id.tfs_session_create_from_path_async(name, source_path, session_path, perform_get=false)async version with auto server-path resolution.tfs_session_create_job_status(job_id)returns queued/running/completed/failed status for session creation job.tfs_session_materialize(name=null, session_path=null, recursive=true)runs explicittf getfor a session path.tfs_session_list()returns the stored session records.tfs_session_validate(name=null, path=null)diagnoses mapping/status for a session or path.tfs_session_suspend(name)stores a suspended state and checkpoint name.tfs_session_discard(name)discards a session and deletes its workspace.tfs_session_resume(name)restores an existing session to active state.tfs_session_promote(name, comment)records a promoted state and stores the promote/checkpoint result.tfs_checkin_preview(path=null, workspace=null, recursive=true)previews pending check-in items.tfs_history(path, stop_after=null, recursive=false)returns TFVC history output.tfs_diff(path, recursive=false, workspace=null)returns TFVC diff output.
Current real-workspace behavior:
- session creation runs
tf workspace /new - maps with
tf workfold /map - skips
tf getby default (fast path) - can populate files with
tfs_session_materialize(...)orperform_get=true
Still not implemented:
- full resume via real unshelve
- formal checkin-based promote flow
- advanced mapping validation and conflict recovery