monocle-mcp 0.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of monocle-mcp might be problematic. Click here for more details.

@@ -0,0 +1,94 @@
1
+ import logging
2
+ import click
3
+ from mcp.server.fastmcp import FastMCP
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+ app = FastMCP(
8
+ "monocle-mcp",
9
+ )
10
+ code_snippets = {
11
+ "python": "from monocle_apptrace import setup_monocle_telemetry"
12
+ "setup_monocle_telemetry(workflow_name='my_workflow')\n",
13
+ "typescript": "import { trace } from 'monocle';\n\ntrace();\n",
14
+ }
15
+ setup_instructions = {
16
+ "python": "pip install monocle_apptrace package and add monocle_apptrace at the end of the requirement.txt for future. This code snippet provided below should be just below other imports in your application code.",
17
+ "typescript": "Install monocle package and add the trace function call at the top of your application. This code snippet provided below should be just below other imports in your application code.",
18
+ }
19
+
20
+ description = {
21
+ "python": "This will automatically trace your Python application, capturing telemetry data for your genAI operations.",
22
+ "typescript": "This will automatically trace your TypeScript application, capturing telemetry data for your genAI operations.",
23
+ }
24
+
25
+
26
+ # Use the existing dictionaries to get language-specific information
27
+ # code_snippet = code_snippets.get(app_language, code_snippets['python'])
28
+ # instructions = setup_instructions.get(app_language, setup_instructions['python'])
29
+ # desc = description.get(app_language, description['python'])
30
+ enable_monocle_prompt = """Do following changes to the project:
31
+ 1. run command 'pip install monocle_apptrace'
32
+ 2. Add following line to requirements.txt in current directory 'monocle_apptrace' if it's not there already
33
+ 3. Add following lines just below other imports in the file if it's not there already:
34
+ from monocle_apptrace import setup_monocle_telemetry
35
+ setup_monocle_telemetry(workflow_name=<module-name>, monocle_exporters_list='file'))
36
+ """
37
+
38
+ monocle_trace_prompt: str = """
39
+ You are a helpful assistant to analyze given Monocle trace data. Review the trace data and provide a summary of whether the execution was successful or if there were any errors. Your job is to analyze the trace data and provide a summary. Be very concise in reporting. Check for errors or problem situations. First provide a headline that indicates status of the trace and if there are problems. If there are problems, then provide a brief summary of the problems. If there are problems, then provide a brief summary of the root causes.
40
+ Use the trace details provided below to understand the data.
41
+
42
+ Monocle trace has recorded the traced the execution of a genAI application. Each step of the genAI operation is captured as span. The trace file is a JSON structure that is an array of span JSON elements. There's a root span that represents the overall execution context.
43
+ The important span JSON elements are as follows:
44
+ - context.trace_id is the unique id common for alls spans.
45
+ - context.span_id is the unique id for each span.
46
+ - parent_id indicates the parent span of that span. The span that has no parent is the root span.
47
+ - status.status_code indicate the status of span. It can be OK or ERROR or UNSET. If the span status is ERROR, then it generally propogated to it's parent and all the way to the root span. This means the entire trace is in error. However, sometimes the parent span will handle the error (eg. if parent name indicagtes 'retry') and the trace will be successful, even though an individual span has error.
48
+ - attributes captures various attributes involved in that span's operation
49
+ - attribute."span.type" indicates the type of operation
50
+ - When the span.type is "workflow", that span captures the summary of the entire application
51
+ - entity.[NUMBER] are the different entties involved in the operation, for example large language model, agent, tool etc
52
+ - entity.type indicates the type of that entity
53
+ - events is an array that captures the details of the operation such as input, output and metadata
54
+ - events array element with name=data.input captures the input provided to the operation
55
+ - events array element with name=data.output captures the output generated by the operation
56
+ - events array element with name=metaata captures the metadata of the operation
57
+ - total_tokens is the count of tokens
58
+ - completion_tokens is the count of ouput tokens
59
+ - prompt_tokens is the count of input tokens
60
+ - finish_type indicates how the operation finished, for example stop sequence or max tokens etc. If the finish_type is not success and indicates problems such as max tokens, then the operation is not successful. Check the status of it's parent span and check if it's due to the finish type of this child span. In that case callout the root cause as the child span error for the parent span error.
61
+ """
62
+
63
+ @app.prompt(name="enable_tracing")
64
+ def enable_monocle_tracing_prompt(app_language: str = "python") -> str:
65
+ """Trace agentic code"""
66
+ return enable_monocle_prompt.format(app_language=app_language)
67
+
68
+
69
+ @app.prompt(name="explain")
70
+ def explain_monocle_tracing_prompt() -> str:
71
+ """Identify root cause from trace"""
72
+ return monocle_trace_prompt
73
+
74
+
75
+ @click.command()
76
+ @click.option(
77
+ "--log-level",
78
+ default="info",
79
+ help="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
80
+ )
81
+ def main(log_level: str) -> int:
82
+ # Configure logging
83
+ logging.basicConfig(
84
+ level=getattr(logging, log_level.upper()),
85
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
86
+ )
87
+
88
+ # Run the FastMCP server using stdio transport
89
+ app.run(transport="stdio")
90
+ return 0
91
+
92
+
93
+ if __name__ == "__main__":
94
+ main() # type: ignore
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: monocle_mcp
3
+ Version: 0.6.6
4
+ Summary: Monocle MCP server: prompts and tools for enabling and analyzing Monocle tracing in GenAI apps.
5
+ Author-email: "Okahu Inc." <okahu-pypi@okahu.ai>
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.8
15
+ Requires-Dist: click>=8.0.0
16
+ Requires-Dist: mcp>=1.12.1
17
+ Requires-Dist: monocle-apptrace>=0.5.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # Monocle MCP server
21
+
22
+ **Monocle** is a community-driven OSS framework for tracing GenAI app code governed as a [Linux Foundation AI & Data project](https://lfaidata.foundation/projects/monocle/) that helps developers and platform engineers building or managing GenAI apps monitor these in prod by making it easy to instrument their code to capture traces that are compliant with open-source cloud-native observability ecosystem.
23
+
24
+ ## What is Monocle MCP server
25
+ The MCP server provided by monocle includes curated prompts and tools that help you enable Monocle tracing in your application and analyze the traces generated by Monocle.
26
+
27
+ ## Use Monocle MCP
28
+
29
+ First install monocle-apptrace: pip install monocle-mcp
30
+
31
+ Open bash and run the following command to run the monocle mcp server with stdio:
32
+ monocle_apptrace
33
+
34
+ If you are using VS Code you can add following entry to your .vscode/mcp.json
35
+
36
+ ```json
37
+ "monocle-mcp-server": {
38
+ "type": "stdio",
39
+ "command": "uvx",
40
+ "args": [
41
+ "monocle_apptrace"
42
+ ],
43
+ "env": {}
44
+ }
45
+ ```
46
+
47
+
@@ -0,0 +1,6 @@
1
+ monocle_mcp/mcp_server.py,sha256=LFdNXbKjP4bMS88E9DdfA70MNn7_D8gikjFuT4pxECQ,5591
2
+ monocle_mcp-0.6.6.dist-info/METADATA,sha256=RBDGFmg5M180yZhd53aCDE1rXGGihik5D6vAMSCFLys,1813
3
+ monocle_mcp-0.6.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ monocle_mcp-0.6.6.dist-info/entry_points.txt,sha256=c6W161rtekrNAOn98Cs9Rm2l4S7BylX0SkUmsDqLdwQ,60
5
+ monocle_mcp-0.6.6.dist-info/licenses/LICENSE,sha256=ay9trLiP5I7ZsFXo6AqtkLYdRqe5S9r-DrPOvsNlZrg,9136
6
+ monocle_mcp-0.6.6.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ monocle_mcp = monocle_mcp.mcp_server:main
@@ -0,0 +1,51 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
37
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
38
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
39
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
40
+
41
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
42
+
43
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
44
+
45
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
46
+
47
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
48
+
49
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
50
+
51
+ END OF TERMS AND CONDITIONS