Chat mode imported from JoshuaWink/vscode-api-expose-extension (
.github/chatmodes/demo.chatmode.md). Copyright stays with the author.
DeepCog Disciplined Foresight: Modularizing capi-mcp-server with fastmcp-template Patterns
Context
- Project Goal: Expose the VSCode
capiCLI as a Model Context Protocol (MCP) server, enabling agent-driven automation and observability with minimal human intervention. - Current State:
capi-mcp-serveris a single-file Python MCP server usingFastMCPand direct tool decorators.- The
fastmcp-templateprovides a modular, registry-driven, and extensible server architecture.
- Intent:
- Refactor
capi-mcp-serverto use the modular, registry-based approach fromfastmcp-templatefor long-term maintainability, extensibility, and agent compatibility.
- Refactor
Why Disciplined Foresight?
- Reason: Ensures the refactor is logically sound, modular, and robust for future growth.
- Memory: Leverages best practices from the template and prior MCP/LLM server architectures.
- Will: Drives purposeful action—scaffolding a maintainable, extensible, and agent-friendly server.
Step-by-Step Plan
- Directory Structure:
- Create
app/withtools.py,resources.py,prompts.py, and__init__.py. - Move tool logic from
server.pytoapp/tools.py. - Add a
register_tools(server)function for dynamic tool registration.
- Create
- Entrypoint Refactor:
- Update
server.pyto instantiateFastMCP, callregister_tools, and run the server. - Prepare for future
register_resourcesandregister_prompts.
- Update
- Registry Pattern:
- Use a list of tool definitions (name, description, factory) for easy extension and testability.
- Register each tool dynamically in
register_tools.
- Extensibility:
- The same pattern can be used for resources and prompts, supporting future agent workflows and LLM integrations.
- Testing & TDD:
- Structure supports adding a
tests/directory for incremental, test-driven development.
- Structure supports adding a
Recap TL;DR
- Refactor
capi-mcp-serverto use a modular, registry-driven architecture inspired byfastmcp-template. - Goal: Long-term maintainability, extensibility, and agent/LLM compatibility.
- Pattern: Move tool logic to
app/tools.py, useregister_tools, and keepserver.pyminimal and declarative. - Outcome: A future-proof, agent-friendly MCP server ready for rapid iteration and onboarding.
This document was generated by DeepCog using the Disciplined Foresight perspective to ensure strategic, maintainable, and extensible architecture for agent-driven automation.