MCP Core Library logo

MCP Core Library

by MCPStudio

The MCP Core Library contains the domain business logic and ports of the MCP server, following a hexagonal architecture. It defines abstractions that represent domain boundaries and remains independent of implementation details.

View on GitHub

Last updated: N/A

What is MCP Core Library?

The MCP Core Library is a crate containing the core business logic and port definitions for the MCP server. It is designed following the principles of hexagonal architecture, ensuring separation of concerns and independence from specific technologies.

How to use MCP Core Library?

To use the MCP Core Library, integrate it into your project as a dependency. Utilize the defined ports (Tool, Transport) and domain entities to implement your specific input adapters and external communication mechanisms. Refer to the crate's documentation for detailed API usage.

Key features of MCP Core Library

  • Domain business logic implementation

  • Primary and secondary port definitions

  • Abstract message types

  • Domain error handling

  • Tool registry

Use cases of MCP Core Library

  • Implementing tool execution within MCP

  • Handling network communication within MCP

  • Defining and managing domain-specific data structures

  • Registering and searching for tools

  • Creating a modular and testable MCP server architecture

FAQ from MCP Core Library

What is hexagonal architecture?

Hexagonal architecture is a software design pattern that aims to create loosely coupled components. It separates the core business logic from external dependencies like UI, databases, or external services.

What are primary and secondary ports?

Primary ports (driving ports) are interfaces used by input adapters to interact with the domain. Secondary ports (driven ports) are interfaces used by the domain to communicate with the outside world.

Why is JSON-RPC excluded from the core crate?

To maintain domain isolation and adhere to hexagonal architecture principles, specific protocol details like JSON-RPC are implemented in external adapters.

What is the ToolRegistry?

The ToolRegistry is a component for managing the registration and search of tools by name. It provides a way to dynamically load and access different tools within the MCP server.

What dependencies does the core crate have?

The core crate depends on basic crates like serde (for serialization) and tokio (for asynchronous types) to remain minimal and preserve domain isolation.