How kartha-ai/agentcare-mcp works
The Agent Care project is an MCP (Model Context Protocol) server built to integrate with EMR systems like Cerner and Epic. It exposes a variety of healthcare tools for FHIR data access and medical research (including PubMed, Clinical Trials, and FDA data) and is designed to work with client applications like Claude Desktop and Goose Desktop.
Main Components
• FHIR Connector: Represent the modules in both the build and src trees under “server/connectors/fhir”. This includes components such as the FhirClient, Formatters, Helper, and Prompter. These components encapsulate FHIR-related functionality used to interface with EMRs.
• Medical Research Connector: Similarly, show the “server/connectors/medical” components (ClinicalTrials, FDA, and PubMed) that allow integrations with external medical research data providers.
• Handlers: Include the PromptHandler and ToolHandler components that manage incoming commands and tool invocations.
• Utilities & Authentication: Illustrate the utility functions and authentication modules (Auth, AuthConfig, Cache). Note that these manage OAuth2 authentication with EMRs, token exchange, and caching of responses.
• Configuration: Mark external configuration files (in the config folder and environment variables) that tailor connectivity for different EMRs (Cerner and Epic).
• External Services:
• Medical Research APIs: Include PubMed, Clinical Trials, and FDA APIs.
• OAuth2 Provider: For handling user authentication and authorization.
• Claude & Goose Desktop: Represent the client/agent interfaces used to interact with the server.
Relationships and Data Flows
• Authentication flow: start with the incoming OAuth login request, handled by the Auth modules, then flowing to the EMRs’ OAuth endpoints.
Architectural Patterns and Principles
• Separation of Concerns: The clear division between connectors (FHIR and Medical), handlers, and utility modules suggests a modular architecture. Each component should be shown as an isolated block working as part of a layered system.
• Client-Server Interaction: Emphasize the separation between external client interfaces (Claude/Goose) and the back-end service logic.
• External Configuration: Note the role of configuration files (.env, JSON configs, etc.) that support different environments (Cerner vs. Epic) by providing unique API endpoints and creds.
Relevant Technologies and Libraries
• Programming Languages: Highlight the use of TypeScript (see src/ folder) which compiles down to JavaScript (build/ folder).
• Node.js Runtime: Indicate that the server runs on Node, as seen through scripts like build/index.js.
• OAuth2: Mark its central role in authentication flows.
• FHIR API integration: Emphasize that this is used extensively to interact with the EMRs.
• Caching Mechanism: Represent the caching logic from "Cache.js" to improve response times.