You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/mcp.md
+27-38Lines changed: 27 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,53 +16,42 @@ weight: 15 # The order in which the post appears in a list of posts. Lower nu
16
16
- The AI model's response will be more context-ware if we provide it external source like databases, file systems, pictures ,...
17
17
- MCP provides a standard way to connect AI-powered applications with external data sources.
18
18
-<br>
19
-
<br>
20
19
21
20
## 2. Model Context Protocol
22
21
- Components overview:
23
22
-<br>
23
+
24
24
- MCP follows a client-server architecture, that included:
25
-
-**MCP Host:** is the main application that integrates with an LLMs and required to connect with external data source
26
-
-**MCP Client:** are components that establish and maintain 1-1 connection with **MCP servers**
27
-
-**MCP Servers:** are components that integrate with external data sources and expose apis to interact with them
28
-
- MCP provides **two transport channels**, with many transport types:
25
+
- MCP provides **two transport channels**, with many transport types:
29
26
-`stdio`: to enable communication through standard I/O streams
30
27
-`SSE`: HTTP
28
+
- ...
29
+
-**MCP Host:** is the main application that integrates with an LLMs and required to connect with external data source.
30
+
*e.g. You’re coding in Cursor and type: “Refactor this function and run tests.” - **Cursor = Host***
31
+
-**MCP Client:** are components that establish/manage and maintain 1-1 connection with **MCP servers**
32
+
e.g. Claude wants to read a file -> **File system client**. Git client .. (basically, we don't see them) -> call MCP Server read_file.
33
+
-**MCP Servers:** are components that integrate with external data sources. They are the external programs that expose Tools, Resources and Prompts via API to the API model via Client.
34
+
*e.g. Filesystem MCP Server*
35
+
- **Tools:** functions that LLMs can call to perform specific actions. *e.g. read_file(path) write_file(path, content) list_directory(path)*
1. Initialization: When a Host application starts it creates N MCP Clients, which exchange information about capabilities and protocol versions via a handshake.
47
+
2. Discovery: Clients requests what capabilities (Tools, Resources, Prompts) the server offers. The Server responds with a list and descriptions.
48
+
3. Context Provision: The Host application can now make resources and prompts available to the user or parses the tools into a LLM compatible format, e.g. JSON Function calling
49
+
4. Invocation: If the LLM determines it needs to use a Tool (e.g., based on the user's request like "What are the open issues in the 'X' repo?"), the Host directs the Client to send an invocation request to the appropriate Server.
50
+
5. Execution: The Server receives the request (e.g., fetch_github_issues with repo 'X'), executes the underlying logic (calls the GitHub API), and gets the result.
51
+
6. Response: The Server sends the result back to the Client.
52
+
7. Completion: The Client relays the result to the Host, which incorporates it into the LLM's context, allowing the LLM to generate a final response for the user based on the fresh, external information.
53
+
62
54
```
63
-
- Notes:
64
-
-`spring-ai-starter-model-anthropic`: to interact with the Claud model
65
-
-`spring-ai-starter-mcp-client`: to configure clients in the application to maintain 1-1 connection with the MCP servers.
66
55
67
-
- Navigate to [Claud](https://platform.claude.com/settings/keys) and create an API key.
0 commit comments