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
This pull request introduces significant updates to the MCP server,
including the addition of an extensible docstring system, restructuring
of file paths, and enhancements to configuration and testing setups.
These changes aim to improve maintainability, scalability, and developer
experience.
### Enhancements to MCP Server Functionality
* Added a new extensible docstring system (`DocstringTemplateSystem`)
that uses Jinja2 templates to dynamically generate method docstrings
based on configuration. This includes the `extensible_docstring`
decorator and `setup_extensible_docstrings` utility for seamless
integration. (`services/mcp-server/src/docstring_system.py`,
`services/mcp-server/src/rag_mcp_server.py`)
[[1]](diffhunk://#diff-0dcdbe141882267f8d9fc27375b94ded2088f5592b35afc540d753db0a4ae571R1-R223)
[[2]](diffhunk://#diff-c8d76fe95b7721b6d9cfcedcef267b70303d5ef731160d3c6d08e5883a4a670dR14-R15)
[[3]](diffhunk://#diff-c8d76fe95b7721b6d9cfcedcef267b70303d5ef731160d3c6d08e5883a4a670dR28-L80)
* Updated the `MCPSettings` class to include detailed configuration
options for `chat_simple` and `chat_with_history` methods, such as
descriptions, parameter details, return types, and examples. These
settings are used by the new docstring system.
(`services/mcp-server/src/settings/mcp_settings.py`)
[[1]](diffhunk://#diff-43115db49b21446e10cae3c5571cc8090a4e0565ea3d7871413d29865140533bL1-R5)
[[2]](diffhunk://#diff-43115db49b21446e10cae3c5571cc8090a4e0565ea3d7871413d29865140533bR34-R66)
### Restructuring and Path Updates
* Refactored file paths in `.vscode/settings.json` and `conftest.py` to
align with the new directory structure under `services/`. This includes
adding `mcp-server/src` and updating imports for backend services.
(`.vscode/settings.json`, `conftest.py`)
[[1]](diffhunk://#diff-a5de3e5871ffcc383a2294845bd3df25d3eeff6c29ad46e3a396577c413bf357L9-R12)
[[2]](diffhunk://#diff-a31c7ed5d35f5ed8233994868c54d625b18e6bacb6794344c4531e62bd9dde59L7-R19)
### Infrastructure and Configuration Updates
* Enhanced the Helm chart configuration (`configmap.yaml`,
`values.yaml`) to support additional metadata for the MCP server, such
as host, descriptions, and examples for chat tools. These changes enable
better customization and documentation.
(`infrastructure/rag/templates/backend/configmap.yaml`,
`infrastructure/rag/values.yaml`)
[[1]](diffhunk://#diff-121c65fa1a9269554fc3a0d7774e34f409e3ce275d2a6c375552eee780ea6ea1L143-R152)
[[2]](diffhunk://#diff-673dd2d3d4e66a8fd4e45f9c1c9900711313f946bf8b6a89e96c954988fc14f3R23-R42)
### Testing and Development Environment Improvements
* Added pytest configuration to `pyproject.toml` in `mcp-server`,
including markers for test categorization (e.g., `unit`, `integration`)
and additional pytest options. (`services/mcp-server/pyproject.toml`)
* Updated `testpaths` in `libs/rag-core-api/pyproject.toml` to use a
list format for consistency with other configurations.
(`libs/rag-core-api/pyproject.toml`)
### Dependency Updates
* Introduced `jinja2` as a new dependency in
`services/mcp-server/pyproject.toml` to support the docstring templating
system. (`services/mcp-server/pyproject.toml`)
---------
Co-authored-by: Andreas Klos <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,27 @@ The MCP server runs as a sidecar container alongside the main RAG backend and ex
78
78
-`chat_simple`: Basic question-answering without conversation history
79
79
-`chat_with_history`: Advanced chat interface with conversation history and returns structured responses with `answer`, `finish_reason`, and `citations`.
80
80
81
+
##### Configuring Tool Documentation
82
+
83
+
The MCP server supports customizable documentation for its tools through environment variables. This allows you to customize the descriptions, parameter explanations, and examples shown to MCP clients. All documentation configuration uses the `MCP_` prefix and can be configured with the [values.yaml](infrastructure/rag/values.yaml). The following configuration options exist:
84
+
85
+
**For `chat_simple` tool:**
86
+
87
+
-`MCP_CHAT_SIMPLE_DESCRIPTION`: Main description of the tool
88
+
-`MCP_CHAT_SIMPLE_PARAMETER_DESCRIPTIONS`: JSON object mapping parameter names to descriptions
89
+
-`MCP_CHAT_SIMPLE_RETURNS`: Description of the return value
90
+
-`MCP_CHAT_SIMPLE_NOTES`: Additional notes about the tool
91
+
-`MCP_CHAT_SIMPLE_EXAMPLES`: Usage examples
92
+
93
+
**For `chat_with_history` tool:**
94
+
95
+
-`MCP_CHAT_WITH_HISTORY_DESCRIPTION`: Main description of the tool
96
+
-`MCP_CHAT_WITH_HISTORY_PARAMETER_DESCRIPTIONS`: JSON object mapping parameter names to descriptions
97
+
-`MCP_CHAT_WITH_HISTORY_RETURNS`: Description of the return value
98
+
-`MCP_CHAT_WITH_HISTORY_NOTES`: Additional notes about the tool
99
+
-`MCP_CHAT_WITH_HISTORY_EXAMPLES`: Usage examples
100
+
101
+
81
102
For further information on configuration and usage, please consult the [MCP Server README](./services/mcp-server/README.md).
Copy file name to clipboardExpand all lines: infrastructure/rag/values.yaml
+47Lines changed: 47 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,53 @@ backend:
20
20
name: "mcp"
21
21
port: "8000"
22
22
host: "0.0.0.0"
23
+
24
+
# Chat simple tool configuration
25
+
# The following configuration for the chat_simple tool will render as follows:
26
+
# """Send a message to the RAG system and get a simple text response.
27
+
28
+
# This is the simplest way to interact with the RAG system - just provide a message and get back the answer as plain text.
29
+
#
30
+
# Parameters
31
+
# ----------
32
+
# session_id : str
33
+
# Unique identifier for the chat session.
34
+
# message : str
35
+
# The message/question to ask the RAG system.
36
+
#
37
+
# Returns
38
+
# -------
39
+
# str
40
+
# The answer from the RAG system as plain text.
41
+
# """
42
+
chatSimpleDescription: "Send a message to the RAG system and get a simple text response.\n\nThis is the simplest way to interact with the RAG system - just provide a message and get back the answer as plain text."
43
+
chatSimpleParameterDescriptions:
44
+
session_id: "Unique identifier for the chat session."
45
+
message: "The message/question to ask the RAG system."
46
+
chatSimpleReturns: "The answer from the RAG system as plain text."
47
+
chatSimpleNotes: ""
48
+
# If you add a Value to chatSimpleNotes e.g. "This tool is best for simple questions that don't require conversation context."
49
+
# it will render to:
50
+
# Notes
51
+
# -----
52
+
# This tool is best for simple questions that don't require conversation context.
53
+
chatSimpleExamples: ""
54
+
# If you add a Value to chatSimpleExamples e.g. "chat_simple(session_id='my-session', message='What is the main topic of the document?')"
55
+
# it will render to:
56
+
# Examples
57
+
# --------
58
+
# chat_simple(session_id='my-session', message='What is the main topic of the document?')
59
+
60
+
# Chat with history tool configuration
61
+
chatWithHistoryDescription: "Send a message with conversation history and get structured response.\n\nProvide conversation history as a simple list of dictionaries.\nEach history item should have 'role' (either 'user' or 'assistant') and 'message' keys."
62
+
chatWithHistoryParameterDescriptions:
63
+
session_id: "Unique identifier for the chat session."
64
+
message: "The current message/question to ask."
65
+
history: "Previous conversation history. Each item should be:\n {\"role\": \"user\" or \"assistant\", \"message\": \"the message text\"}"
66
+
chatWithHistoryReturns: "Response containing:\n - answer: The response text\n - finish_reason: Why the response ended\n - citations: List of source documents used (simplified)"
The MCP server supports customizable documentation for its tools through environment variables. This allows you to customize the descriptions, parameter explanations, and examples shown to MCP clients.
84
+
85
+
#### Chat Simple Tool Documentation
86
+
87
+
-`MCP_CHAT_SIMPLE_DESCRIPTION`: Main description of the tool
88
+
-`MCP_CHAT_SIMPLE_PARAMETER_DESCRIPTIONS`: JSON object mapping parameter names to descriptions
89
+
-`MCP_CHAT_SIMPLE_RETURNS`: Description of the return value
90
+
-`MCP_CHAT_SIMPLE_NOTES`: Additional notes about the tool
91
+
-`MCP_CHAT_SIMPLE_EXAMPLES`: Usage examples
92
+
93
+
#### Chat With History Tool Documentation
94
+
95
+
-`MCP_CHAT_WITH_HISTORY_DESCRIPTION`: Main description of the tool
96
+
-`MCP_CHAT_WITH_HISTORY_PARAMETER_DESCRIPTIONS`: JSON object mapping parameter names to descriptions
97
+
-`MCP_CHAT_WITH_HISTORY_RETURNS`: Description of the return value
98
+
-`MCP_CHAT_WITH_HISTORY_NOTES`: Additional notes about the tool
99
+
-`MCP_CHAT_WITH_HISTORY_EXAMPLES`: Usage examples
100
+
101
+
#### Example Configuration
102
+
103
+
```env
104
+
# Custom tool descriptions
105
+
MCP_CHAT_SIMPLE_DESCRIPTION="Ask questions about your documents and get instant answers."
106
+
MCP_CHAT_SIMPLE_EXAMPLES="chat_simple(session_id='my-session', message='What is the main topic of the document?')"
107
+
108
+
# Custom parameter descriptions (JSON format)
109
+
MCP_CHAT_SIMPLE_PARAMETER_DESCRIPTIONS='{"session_id": "A unique session identifier for your conversation", "message": "Your question about the documents"}'
110
+
111
+
# Custom return description
112
+
MCP_CHAT_SIMPLE_RETURNS="A plain text answer based on your document content"
113
+
114
+
# Notes about usage
115
+
MCP_CHAT_SIMPLE_NOTES="This tool is best for simple questions that don't require conversation context."
116
+
```
117
+
118
+
#### Template Rendering
119
+
120
+
The MCP server uses Jinja2 templates to generate tool documentation in **numpy docstring format**. When the environment variables are set, they are rendered into a structured docstring that MCP clients can parse and display.
121
+
122
+
**Example of rendered docstring:**
123
+
124
+
Given the configuration above, the `chat_simple` tool's docstring would be rendered as:
"""Ask questions about your documents and get instant answers.
129
+
130
+
Parameters
131
+
----------
132
+
session_id : str
133
+
A unique session identifier for your conversation
134
+
message : str
135
+
Your question about the documents
136
+
137
+
Returns
138
+
-------
139
+
str
140
+
A plain text answer based on your document content
141
+
142
+
Notes
143
+
-----
144
+
This tool is best for simple questions that don't require conversation context.
145
+
146
+
Examples
147
+
--------
148
+
chat_simple(session_id='my-session', message='What is the main topic of the document?')
149
+
"""
150
+
```
151
+
152
+
This numpy-style docstring format ensures compatibility with documentation tools and provides clear, structured information to MCP clients about how to use each tool.
153
+
154
+
### Helm Chart Configuration
155
+
156
+
For production deployments, the MCP server documentation can be configured through the Helm chart's `values.yaml` file. This provides a structured way to manage tool documentation across different environments.
157
+
158
+
The MCP configuration is located under `backend.mcp` in the [values.yaml](../../infrastructure/rag/values.yaml) file:
159
+
160
+
```yaml
161
+
backend:
162
+
mcp:
163
+
# Basic MCP server settings
164
+
name: "mcp"
165
+
port: "8000"
166
+
host: "0.0.0.0"
167
+
168
+
# Chat simple tool configuration
169
+
chatSimpleDescription: "Send a message to the RAG system and get a simple text response.\n\nThis is the simplest way to interact with the RAG system - just provide a message and get back the answer as plain text."
170
+
chatSimpleParameterDescriptions:
171
+
session_id: "Unique identifier for the chat session."
172
+
message: "The message/question to ask the RAG system."
173
+
chatSimpleReturns: "The answer from the RAG system as plain text."
174
+
chatSimpleNotes: ""
175
+
chatSimpleExamples: ""
176
+
177
+
# Chat with history tool configuration
178
+
chatWithHistoryDescription: "Send a message with conversation history and get structured response.\n\nProvide conversation history as a simple list of dictionaries.\nEach history item should have 'role' (either 'user' or 'assistant') and 'message' keys."
179
+
chatWithHistoryParameterDescriptions:
180
+
session_id: "Unique identifier for the chat session."
181
+
message: "The current message/question to ask."
182
+
history: "Previous conversation history. Each item should be:\n {\"role\": \"user\" or \"assistant\", \"message\": \"the message text\"}"
183
+
chatWithHistoryReturns: "Response containing:\n - answer: The response text\n - finish_reason: Why the response ended\n - citations: List of source documents used (simplified)"
184
+
chatWithHistoryNotes: ""
185
+
chatWithHistoryExamples: ""
186
+
```
187
+
188
+
These values are automatically converted to the appropriate environment variables (with `MCP_` prefix) when the Helm chart is deployed. The `chatSimpleParameterDescriptions` and `chatWithHistoryParameterDescriptions` dictionaries are automatically converted to JSON format for consumption by the MCP server.
189
+
190
+
This approach allows you to:
191
+
192
+
- Manage documentation consistently across environments
193
+
- Version control your tool documentation
194
+
- Use different documentation for different deployments (dev, staging, production)
195
+
- Leverage Helm's templating features for dynamic documentation
196
+
81
197
## Deployment
82
198
83
199
The MCP server is designed to be deployed alongside the main RAG backend as a sidecar container. A detailed explanation of the deployment can be found in the [main README](../README.md) and the [infrastructure README](../rag-infrastructure/README.md) of the project.
0 commit comments