MCP Specification

The MCP specification defines the authoritative technical requirements for implementing the Model Context Protocol (MCP), an open standard that enables seamless integration between LLM applications and external data sources.

Jump to section

Jump to section

Jump to section

This comprehensive guide covers every aspect of the MCP spec, from core protocol requirements to implementation details.

The MCP spec serves as the definitive reference for developers building MCP servers, clients, and integrations. Based on the official TypeScript schema and JSON-RPC 2.0 foundations, this specification ensures consistent implementation across the entire MCP ecosystem.

How MCP architecture works

MCP uses a three-part structure that works together to connect language models with external tools and data. Each part has a specific job that helps maintain security and organization.

Component

Primary Role

Relationship

Key Responsibilities

Host

Central coordinator

Manages clients

Security, permissions, system control

Client

Intermediary

1:1 with server

Session management, message routing

Server

Resource provider

Connected to client

Provide tools, data, and resources

Host

The host runs the language model and manages all client connections. It's like the main office in a company that oversees everything. The host decides which clients can connect to which servers and what they're allowed to do. This central control helps keep the system secure and stable.

Client

The client connects one host to one server. It's like a dedicated phone line between two people. Each client keeps track of its own conversation and doesn't mix information with other clients. This one-to-one relationship helps keep data organized and prevents confusion.

Server

The server provides tools and data to the client. It's like a library or toolkit that the client can access. Servers can run on the same computer or somewhere else on the network. Each server connection is separate from others, which helps prevent data from leaking between different sessions.

This architecture makes MCP both flexible and secure. The clear separation of roles means each part can focus on its specific job, making the whole system more reliable.

Understanding the base protocol and schemas

MCP builds on established communication patterns to ensure reliable data exchange between systems. These foundations make the protocol predictable and compatible with many different environments.

JSON-RPC foundation

MCP uses JSON-RPC 2.0 for its messages. This is a simple way for one system to call functions on another system using JSON format. For example, when a client wants to use a tool on a server, it sends a JSON-RPC message that includes:

  • The method name

  • Any parameters needed

  • An ID to track the response

The server then sends back a response with the results and the same ID. This approach is widely used and well-understood by developers.

Session management

Unlike regular web requests where each request stands alone, MCP keeps track of conversations through sessions. This means the client and server remember previous messages and maintain context throughout their interaction.

Sessions help MCP keep track of:

  • Which tools are available

  • What resources have been shared

  • Any ongoing operations

This stateful approach is crucial for complex interactions where context matters.

Schema handling

MCP uses schemas to define the structure of its messages. These schemas are written in TypeScript and converted to JSON Schema format. They act like blueprints that describe what fields should be in each message and what type of data those fields should contain.

All messages in MCP are checked against these schemas to make sure they're formatted correctly. This validation helps catch errors early and ensures that different implementations of MCP can work together smoothly.

The current MCP specification, including all schema definitions, is available at modelcontextprotocol.io.

Security and authorization in MCP

Security in MCP starts with the host, which controls all permissions and connections. The host decides which clients can connect to which servers and what actions they can perform, similar to how a security guard checks IDs at a building entrance.

Each client in MCP operates in its own isolated session. This isolation is like having separate rooms for different conversations - what happens in one room doesn't affect the others. This design prevents data from leaking between sessions, even when multiple clients are active at the same time.

For authentication, MCP uses OAuth - a standard protocol many websites use for login systems. This allows MCP to connect with existing identity systems that organizations already have in place.

Security highlights:

  • Permission model: The host controls which clients can access which servers and tools

  • Data isolation: Each session is separate, preventing information leakage between sessions

  • Authentication: Standard OAuth flows make integration with existing systems easier

  • Best practices: Include limiting access to only what's needed and keeping logs of activity

These security features make MCP suitable for enterprise environments where data protection is essential. The protocol is designed to maintain clear boundaries while still allowing flexible connections between systems.

Getting started with MCP protocol

1. Choose a language or framework

To start working with MCP, first pick a programming language that fits your project. Several languages have libraries that support MCP:

  • JavaScript/TypeScript: Has official libraries with complete support

  • Python: Good community support for data-focused applications

  • Java, C#, and others: Have varying levels of support through community projects

The choice depends on what you're already using and what features you need. Official SDKs can be found in the modelcontextprotocol GitHub organization.

2. Set up basic services

An MCP system needs three main components working together:

// Example of how components connect in pseudocode
const host = new MCPHost();
const client = host.createClient();
const server = new MCPServer();
client.connect(server);

The host manages security and creates clients. Each client connects to one server. The server provides tools, prompts, or resources that the client can use. All components communicate using the structure defined in the MCP specification.

3. Validate requests and responses

Every message in MCP follows a specific structure defined by schemas. Validation ensures messages match these structures, catching problems early before they cause errors.

For example, if a tool expects a number parameter but receives text, validation would catch this mismatch. Most MCP libraries include built-in validation to handle this automatically.

4. Test and iterate

Testing helps ensure your MCP implementation works correctly. Start with simple tests for basic functionality, then add more complex scenarios:

  • Test tool execution with valid and invalid inputs

  • Check how the system handles timeouts

  • Verify that permissions work as expected

As you find issues, update your implementation and test again. This cycle helps build a reliable system that follows the MCP specification correctly.

Common implementation challenges

When implementing MCP, several common challenges tend to arise. Understanding these issues ahead of time can save significant troubleshooting effort.

  • Schema mismatches between client and server
    When the client and server have different expectations about message formats, communication breaks down. This often happens when one component is updated but the other isn't.

    To solve this: Use automated schema validation during development and testing. Keep all components synchronized when making updates.

  • Session management complexity
    Sessions need to be properly isolated and maintained. When session data leaks between connections or gets lost, it causes unpredictable behavior.

    To solve this: Use the session management features provided by MCP libraries rather than creating your own. Test with multiple simultaneous sessions to verify isolation.

  • Security misconfigurations
    Incorrect permission settings can either block legitimate access or allow unauthorized access. Both situations cause problems.

    To solve this: Start with restrictive permissions and gradually open access as needed. Use standard authentication flows rather than custom solutions.

  • Performance bottlenecks
    As usage increases, message handling may become slow or resource-intensive. This affects response times and system stability.

    To solve this: Use asynchronous processing where possible. Monitor performance metrics to identify bottlenecks early.

At Stainless, we've encountered these challenges when converting OpenAPI specifications to MCP servers. One particular issue involves handling complex schemas with nested references, which requires careful resolution to maintain compatibility.

Where it all leads for the future of MCP

The Model Context Protocol is still evolving, with several trends shaping its future direction. As more organizations adopt LLMs in their workflows, MCP's role as a standardized connection method will likely grow in importance.

We're seeing increased integration with cloud infrastructure, making it easier to deploy MCP components in scalable environments. There's also growing support for real-time data streams, allowing more dynamic interactions between LLMs and external systems.

At Stainless, we've been working on tools that help organizations convert their existing APIs into MCP servers. This conversion process involves mapping API endpoints to MCP tools while handling schema transformations and reference resolution.

One challenge we've encountered is that different MCP clients have varying limitations in how they interpret JSON Schemas. Claude Desktop handles complex schemas well, but other clients may have restrictions that require schema simplification.

For organizations looking to implement MCP, starting with a clear understanding of the specification provides a solid foundation. From there, choosing appropriate tools and addressing common challenges leads to successful implementations that connect AI systems with external resources effectively.

FAQs about MCP specification

What are the primary differences between MCP and standard HTTP protocol specifications?

MCP maintains session state across multiple requests while HTTP is stateless. MCP also includes specialized structures for AI tools, prompts, and resources that don't exist in standard HTTP, making it specifically designed for AI system integration rather than general web communication.

Can MCP be implemented with existing API infrastructure?

Yes, existing APIs can be wrapped with an MCP layer that translates between the API's native format and the MCP protocol. This approach allows organizations to expose their existing services to LLMs without rebuilding them from scratch.

What programming languages have the best support for implementing MCP servers?

JavaScript/TypeScript and Python currently have the most mature support for MCP implementation. These languages have well-maintained SDKs that follow the current specification closely, though support for other languages is growing through community contributions.

How does MCP.io relate to the broader MCP specification?

MCP.io is the official documentation site for the Model Context Protocol. It hosts the specification documents, schema definitions, and implementation guides. The site serves as the authoritative reference for the protocol standard.

This comprehensive guide covers every aspect of the MCP spec, from core protocol requirements to implementation details.

The MCP spec serves as the definitive reference for developers building MCP servers, clients, and integrations. Based on the official TypeScript schema and JSON-RPC 2.0 foundations, this specification ensures consistent implementation across the entire MCP ecosystem.

How MCP architecture works

MCP uses a three-part structure that works together to connect language models with external tools and data. Each part has a specific job that helps maintain security and organization.

Component

Primary Role

Relationship

Key Responsibilities

Host

Central coordinator

Manages clients

Security, permissions, system control

Client

Intermediary

1:1 with server

Session management, message routing

Server

Resource provider

Connected to client

Provide tools, data, and resources

Host

The host runs the language model and manages all client connections. It's like the main office in a company that oversees everything. The host decides which clients can connect to which servers and what they're allowed to do. This central control helps keep the system secure and stable.

Client

The client connects one host to one server. It's like a dedicated phone line between two people. Each client keeps track of its own conversation and doesn't mix information with other clients. This one-to-one relationship helps keep data organized and prevents confusion.

Server

The server provides tools and data to the client. It's like a library or toolkit that the client can access. Servers can run on the same computer or somewhere else on the network. Each server connection is separate from others, which helps prevent data from leaking between different sessions.

This architecture makes MCP both flexible and secure. The clear separation of roles means each part can focus on its specific job, making the whole system more reliable.

Understanding the base protocol and schemas

MCP builds on established communication patterns to ensure reliable data exchange between systems. These foundations make the protocol predictable and compatible with many different environments.

JSON-RPC foundation

MCP uses JSON-RPC 2.0 for its messages. This is a simple way for one system to call functions on another system using JSON format. For example, when a client wants to use a tool on a server, it sends a JSON-RPC message that includes:

  • The method name

  • Any parameters needed

  • An ID to track the response

The server then sends back a response with the results and the same ID. This approach is widely used and well-understood by developers.

Session management

Unlike regular web requests where each request stands alone, MCP keeps track of conversations through sessions. This means the client and server remember previous messages and maintain context throughout their interaction.

Sessions help MCP keep track of:

  • Which tools are available

  • What resources have been shared

  • Any ongoing operations

This stateful approach is crucial for complex interactions where context matters.

Schema handling

MCP uses schemas to define the structure of its messages. These schemas are written in TypeScript and converted to JSON Schema format. They act like blueprints that describe what fields should be in each message and what type of data those fields should contain.

All messages in MCP are checked against these schemas to make sure they're formatted correctly. This validation helps catch errors early and ensures that different implementations of MCP can work together smoothly.

The current MCP specification, including all schema definitions, is available at modelcontextprotocol.io.

Security and authorization in MCP

Security in MCP starts with the host, which controls all permissions and connections. The host decides which clients can connect to which servers and what actions they can perform, similar to how a security guard checks IDs at a building entrance.

Each client in MCP operates in its own isolated session. This isolation is like having separate rooms for different conversations - what happens in one room doesn't affect the others. This design prevents data from leaking between sessions, even when multiple clients are active at the same time.

For authentication, MCP uses OAuth - a standard protocol many websites use for login systems. This allows MCP to connect with existing identity systems that organizations already have in place.

Security highlights:

  • Permission model: The host controls which clients can access which servers and tools

  • Data isolation: Each session is separate, preventing information leakage between sessions

  • Authentication: Standard OAuth flows make integration with existing systems easier

  • Best practices: Include limiting access to only what's needed and keeping logs of activity

These security features make MCP suitable for enterprise environments where data protection is essential. The protocol is designed to maintain clear boundaries while still allowing flexible connections between systems.

Getting started with MCP protocol

1. Choose a language or framework

To start working with MCP, first pick a programming language that fits your project. Several languages have libraries that support MCP:

  • JavaScript/TypeScript: Has official libraries with complete support

  • Python: Good community support for data-focused applications

  • Java, C#, and others: Have varying levels of support through community projects

The choice depends on what you're already using and what features you need. Official SDKs can be found in the modelcontextprotocol GitHub organization.

2. Set up basic services

An MCP system needs three main components working together:

// Example of how components connect in pseudocode
const host = new MCPHost();
const client = host.createClient();
const server = new MCPServer();
client.connect(server);

The host manages security and creates clients. Each client connects to one server. The server provides tools, prompts, or resources that the client can use. All components communicate using the structure defined in the MCP specification.

3. Validate requests and responses

Every message in MCP follows a specific structure defined by schemas. Validation ensures messages match these structures, catching problems early before they cause errors.

For example, if a tool expects a number parameter but receives text, validation would catch this mismatch. Most MCP libraries include built-in validation to handle this automatically.

4. Test and iterate

Testing helps ensure your MCP implementation works correctly. Start with simple tests for basic functionality, then add more complex scenarios:

  • Test tool execution with valid and invalid inputs

  • Check how the system handles timeouts

  • Verify that permissions work as expected

As you find issues, update your implementation and test again. This cycle helps build a reliable system that follows the MCP specification correctly.

Common implementation challenges

When implementing MCP, several common challenges tend to arise. Understanding these issues ahead of time can save significant troubleshooting effort.

  • Schema mismatches between client and server
    When the client and server have different expectations about message formats, communication breaks down. This often happens when one component is updated but the other isn't.

    To solve this: Use automated schema validation during development and testing. Keep all components synchronized when making updates.

  • Session management complexity
    Sessions need to be properly isolated and maintained. When session data leaks between connections or gets lost, it causes unpredictable behavior.

    To solve this: Use the session management features provided by MCP libraries rather than creating your own. Test with multiple simultaneous sessions to verify isolation.

  • Security misconfigurations
    Incorrect permission settings can either block legitimate access or allow unauthorized access. Both situations cause problems.

    To solve this: Start with restrictive permissions and gradually open access as needed. Use standard authentication flows rather than custom solutions.

  • Performance bottlenecks
    As usage increases, message handling may become slow or resource-intensive. This affects response times and system stability.

    To solve this: Use asynchronous processing where possible. Monitor performance metrics to identify bottlenecks early.

At Stainless, we've encountered these challenges when converting OpenAPI specifications to MCP servers. One particular issue involves handling complex schemas with nested references, which requires careful resolution to maintain compatibility.

Where it all leads for the future of MCP

The Model Context Protocol is still evolving, with several trends shaping its future direction. As more organizations adopt LLMs in their workflows, MCP's role as a standardized connection method will likely grow in importance.

We're seeing increased integration with cloud infrastructure, making it easier to deploy MCP components in scalable environments. There's also growing support for real-time data streams, allowing more dynamic interactions between LLMs and external systems.

At Stainless, we've been working on tools that help organizations convert their existing APIs into MCP servers. This conversion process involves mapping API endpoints to MCP tools while handling schema transformations and reference resolution.

One challenge we've encountered is that different MCP clients have varying limitations in how they interpret JSON Schemas. Claude Desktop handles complex schemas well, but other clients may have restrictions that require schema simplification.

For organizations looking to implement MCP, starting with a clear understanding of the specification provides a solid foundation. From there, choosing appropriate tools and addressing common challenges leads to successful implementations that connect AI systems with external resources effectively.

FAQs about MCP specification

What are the primary differences between MCP and standard HTTP protocol specifications?

MCP maintains session state across multiple requests while HTTP is stateless. MCP also includes specialized structures for AI tools, prompts, and resources that don't exist in standard HTTP, making it specifically designed for AI system integration rather than general web communication.

Can MCP be implemented with existing API infrastructure?

Yes, existing APIs can be wrapped with an MCP layer that translates between the API's native format and the MCP protocol. This approach allows organizations to expose their existing services to LLMs without rebuilding them from scratch.

What programming languages have the best support for implementing MCP servers?

JavaScript/TypeScript and Python currently have the most mature support for MCP implementation. These languages have well-maintained SDKs that follow the current specification closely, though support for other languages is growing through community contributions.

How does MCP.io relate to the broader MCP specification?

MCP.io is the official documentation site for the Model Context Protocol. It hosts the specification documents, schema definitions, and implementation guides. The site serves as the authoritative reference for the protocol standard.

This comprehensive guide covers every aspect of the MCP spec, from core protocol requirements to implementation details.

The MCP spec serves as the definitive reference for developers building MCP servers, clients, and integrations. Based on the official TypeScript schema and JSON-RPC 2.0 foundations, this specification ensures consistent implementation across the entire MCP ecosystem.

How MCP architecture works

MCP uses a three-part structure that works together to connect language models with external tools and data. Each part has a specific job that helps maintain security and organization.

Component

Primary Role

Relationship

Key Responsibilities

Host

Central coordinator

Manages clients

Security, permissions, system control

Client

Intermediary

1:1 with server

Session management, message routing

Server

Resource provider

Connected to client

Provide tools, data, and resources

Host

The host runs the language model and manages all client connections. It's like the main office in a company that oversees everything. The host decides which clients can connect to which servers and what they're allowed to do. This central control helps keep the system secure and stable.

Client

The client connects one host to one server. It's like a dedicated phone line between two people. Each client keeps track of its own conversation and doesn't mix information with other clients. This one-to-one relationship helps keep data organized and prevents confusion.

Server

The server provides tools and data to the client. It's like a library or toolkit that the client can access. Servers can run on the same computer or somewhere else on the network. Each server connection is separate from others, which helps prevent data from leaking between different sessions.

This architecture makes MCP both flexible and secure. The clear separation of roles means each part can focus on its specific job, making the whole system more reliable.

Understanding the base protocol and schemas

MCP builds on established communication patterns to ensure reliable data exchange between systems. These foundations make the protocol predictable and compatible with many different environments.

JSON-RPC foundation

MCP uses JSON-RPC 2.0 for its messages. This is a simple way for one system to call functions on another system using JSON format. For example, when a client wants to use a tool on a server, it sends a JSON-RPC message that includes:

  • The method name

  • Any parameters needed

  • An ID to track the response

The server then sends back a response with the results and the same ID. This approach is widely used and well-understood by developers.

Session management

Unlike regular web requests where each request stands alone, MCP keeps track of conversations through sessions. This means the client and server remember previous messages and maintain context throughout their interaction.

Sessions help MCP keep track of:

  • Which tools are available

  • What resources have been shared

  • Any ongoing operations

This stateful approach is crucial for complex interactions where context matters.

Schema handling

MCP uses schemas to define the structure of its messages. These schemas are written in TypeScript and converted to JSON Schema format. They act like blueprints that describe what fields should be in each message and what type of data those fields should contain.

All messages in MCP are checked against these schemas to make sure they're formatted correctly. This validation helps catch errors early and ensures that different implementations of MCP can work together smoothly.

The current MCP specification, including all schema definitions, is available at modelcontextprotocol.io.

Security and authorization in MCP

Security in MCP starts with the host, which controls all permissions and connections. The host decides which clients can connect to which servers and what actions they can perform, similar to how a security guard checks IDs at a building entrance.

Each client in MCP operates in its own isolated session. This isolation is like having separate rooms for different conversations - what happens in one room doesn't affect the others. This design prevents data from leaking between sessions, even when multiple clients are active at the same time.

For authentication, MCP uses OAuth - a standard protocol many websites use for login systems. This allows MCP to connect with existing identity systems that organizations already have in place.

Security highlights:

  • Permission model: The host controls which clients can access which servers and tools

  • Data isolation: Each session is separate, preventing information leakage between sessions

  • Authentication: Standard OAuth flows make integration with existing systems easier

  • Best practices: Include limiting access to only what's needed and keeping logs of activity

These security features make MCP suitable for enterprise environments where data protection is essential. The protocol is designed to maintain clear boundaries while still allowing flexible connections between systems.

Getting started with MCP protocol

1. Choose a language or framework

To start working with MCP, first pick a programming language that fits your project. Several languages have libraries that support MCP:

  • JavaScript/TypeScript: Has official libraries with complete support

  • Python: Good community support for data-focused applications

  • Java, C#, and others: Have varying levels of support through community projects

The choice depends on what you're already using and what features you need. Official SDKs can be found in the modelcontextprotocol GitHub organization.

2. Set up basic services

An MCP system needs three main components working together:

// Example of how components connect in pseudocode
const host = new MCPHost();
const client = host.createClient();
const server = new MCPServer();
client.connect(server);

The host manages security and creates clients. Each client connects to one server. The server provides tools, prompts, or resources that the client can use. All components communicate using the structure defined in the MCP specification.

3. Validate requests and responses

Every message in MCP follows a specific structure defined by schemas. Validation ensures messages match these structures, catching problems early before they cause errors.

For example, if a tool expects a number parameter but receives text, validation would catch this mismatch. Most MCP libraries include built-in validation to handle this automatically.

4. Test and iterate

Testing helps ensure your MCP implementation works correctly. Start with simple tests for basic functionality, then add more complex scenarios:

  • Test tool execution with valid and invalid inputs

  • Check how the system handles timeouts

  • Verify that permissions work as expected

As you find issues, update your implementation and test again. This cycle helps build a reliable system that follows the MCP specification correctly.

Common implementation challenges

When implementing MCP, several common challenges tend to arise. Understanding these issues ahead of time can save significant troubleshooting effort.

  • Schema mismatches between client and server
    When the client and server have different expectations about message formats, communication breaks down. This often happens when one component is updated but the other isn't.

    To solve this: Use automated schema validation during development and testing. Keep all components synchronized when making updates.

  • Session management complexity
    Sessions need to be properly isolated and maintained. When session data leaks between connections or gets lost, it causes unpredictable behavior.

    To solve this: Use the session management features provided by MCP libraries rather than creating your own. Test with multiple simultaneous sessions to verify isolation.

  • Security misconfigurations
    Incorrect permission settings can either block legitimate access or allow unauthorized access. Both situations cause problems.

    To solve this: Start with restrictive permissions and gradually open access as needed. Use standard authentication flows rather than custom solutions.

  • Performance bottlenecks
    As usage increases, message handling may become slow or resource-intensive. This affects response times and system stability.

    To solve this: Use asynchronous processing where possible. Monitor performance metrics to identify bottlenecks early.

At Stainless, we've encountered these challenges when converting OpenAPI specifications to MCP servers. One particular issue involves handling complex schemas with nested references, which requires careful resolution to maintain compatibility.

Where it all leads for the future of MCP

The Model Context Protocol is still evolving, with several trends shaping its future direction. As more organizations adopt LLMs in their workflows, MCP's role as a standardized connection method will likely grow in importance.

We're seeing increased integration with cloud infrastructure, making it easier to deploy MCP components in scalable environments. There's also growing support for real-time data streams, allowing more dynamic interactions between LLMs and external systems.

At Stainless, we've been working on tools that help organizations convert their existing APIs into MCP servers. This conversion process involves mapping API endpoints to MCP tools while handling schema transformations and reference resolution.

One challenge we've encountered is that different MCP clients have varying limitations in how they interpret JSON Schemas. Claude Desktop handles complex schemas well, but other clients may have restrictions that require schema simplification.

For organizations looking to implement MCP, starting with a clear understanding of the specification provides a solid foundation. From there, choosing appropriate tools and addressing common challenges leads to successful implementations that connect AI systems with external resources effectively.

FAQs about MCP specification

What are the primary differences between MCP and standard HTTP protocol specifications?

MCP maintains session state across multiple requests while HTTP is stateless. MCP also includes specialized structures for AI tools, prompts, and resources that don't exist in standard HTTP, making it specifically designed for AI system integration rather than general web communication.

Can MCP be implemented with existing API infrastructure?

Yes, existing APIs can be wrapped with an MCP layer that translates between the API's native format and the MCP protocol. This approach allows organizations to expose their existing services to LLMs without rebuilding them from scratch.

What programming languages have the best support for implementing MCP servers?

JavaScript/TypeScript and Python currently have the most mature support for MCP implementation. These languages have well-maintained SDKs that follow the current specification closely, though support for other languages is growing through community contributions.

How does MCP.io relate to the broader MCP specification?

MCP.io is the official documentation site for the Model Context Protocol. It hosts the specification documents, schema definitions, and implementation guides. The site serves as the authoritative reference for the protocol standard.

Featured MCP Resources

Essential events, guides and insights to help you master MCP server development.

Featured MCP Resources

Essential events, guides and insights to help you master MCP server development.

Featured MCP Resources

Essential events, guides and insights to help you master MCP server development.