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: docs/quickstart/server.mdx
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,19 @@ This quickstart assumes you have familiarity with:
46
46
- Python
47
47
- LLMs like Claude
48
48
49
+
### Guidance on Logging Best Practices in MCP Servers
50
+
51
+
When implementing MCP servers, it is crucial that developers avoid using print statements that write messages to standard output.
52
+
Certain MCP hosts and clients might be able to deal with these extraneous outputs, but it could result in unexpected behavior in majority of the MCP clients.
53
+
54
+
Logging messages to standard output could corrupt the structured output and format expected by the clients thus breaking the protocol. Using print functionality in your programming language of choice to send log messages to standard output could make your MCP server unusable.
55
+
56
+
Here are some tips you can use to avoid this problem:
57
+
58
+
- use the built-in logging functionality available in your language specific SDK
59
+
- if you are building your own MCP server from scratch without the SDK, please using logging mechanisms that do not print messages to standard output
60
+
- configure the log levels for your application accordingly
0 commit comments