openlayer-mcp 0.1.0__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.
@@ -0,0 +1,6 @@
1
+ from .openlayer_platform import mcp
2
+
3
+
4
+ def main():
5
+ """Run the Openlayer MCP server."""
6
+ mcp.run(transport="stdio")
@@ -0,0 +1,4 @@
1
+ from . import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,164 @@
1
+ """Openlayer platform MCP server.
2
+
3
+ Provides tools that an MCP client can use to interact with the Openlayer
4
+ platform.
5
+ """
6
+
7
+ import os
8
+ from typing import Dict, List
9
+
10
+ from mcp.server.fastmcp import FastMCP
11
+ from openlayer import Openlayer
12
+ from openlayer.lib.data import commit
13
+
14
+ mcp = FastMCP("openlayer-mcp")
15
+ client = Openlayer()
16
+
17
+
18
+ # --------------------------------- Projects --------------------------------- #
19
+ @mcp.tool()
20
+ def list_projects() -> List[Dict]:
21
+ """Get a list of the projects in the user's workspace."""
22
+ project_list = client.projects.list()
23
+ return [item.model_dump() for item in project_list.items]
24
+
25
+
26
+ @mcp.tool()
27
+ def create_project(
28
+ name: str,
29
+ task_type: str,
30
+ description: str,
31
+ ) -> Dict:
32
+ """Create a new project in the user's workspace.
33
+
34
+ Args:
35
+ name: The name of the project to create.
36
+ task_type: The type of task the project will be used for. Must be one of
37
+ 'llm-base', 'tabular-classification', 'tabular-regression', or
38
+ 'text-classification'.
39
+ description: A short description for the project.
40
+ """
41
+ project = client.projects.create(
42
+ name=name,
43
+ task_type=task_type,
44
+ description=description,
45
+ )
46
+ return project.model_dump()
47
+
48
+
49
+ # ---------------------------------- Commits --------------------------------- #
50
+ @mcp.tool()
51
+ def list_commits(project_id: str) -> List[Dict]:
52
+ """List the commits in a project.
53
+
54
+ Args:
55
+ project_id: The ID of the project to list the commits for.
56
+ """
57
+ commits = client.projects.commits.list(project_id=project_id)
58
+ return [item.model_dump() for item in commits.items]
59
+
60
+
61
+ @mcp.tool()
62
+ def retrieve_commit(project_version_id: str) -> Dict:
63
+ """Retrieve a commit by ID.
64
+
65
+ Args:
66
+ project_version_id: The ID of the commit to retrieve.
67
+ """
68
+ commit = client.commits.retrieve(project_version_id=project_version_id)
69
+ return commit.model_dump()
70
+
71
+
72
+ @mcp.tool()
73
+ def push_commit(
74
+ project_id: str,
75
+ directory: str,
76
+ message: str = "New commit",
77
+ ) -> str:
78
+ """Push a commit to the project.
79
+
80
+ Args:
81
+ project_id: The ID of the project to push the commit to.
82
+ directory: The directory containing the files to push. Usually has at least
83
+ an `openlayer.json` file.
84
+ message: The commit message.
85
+ """
86
+ # Check if the directory contains an openlayer.json file
87
+ if not os.path.exists(os.path.join(directory, "openlayer.json")):
88
+ raise ValueError(
89
+ f"Directory {directory} does not contain an openlayer.json file, so "
90
+ "it is not prepared to be pushed to Openlayer."
91
+ )
92
+ try:
93
+ commit.push(
94
+ client=client,
95
+ directory=directory,
96
+ project_id=project_id,
97
+ message=message,
98
+ )
99
+ except Exception as exc:
100
+ raise ValueError(f"Error pushing commit: {exc}")
101
+ return "Commit pushed successfully."
102
+
103
+
104
+ # ---------------------------- Inference pipelines --------------------------- #
105
+ @mcp.tool()
106
+ def list_inference_pipelines(project_id: str) -> List[Dict]:
107
+ """List the inference pipelines in a project."""
108
+ inference_pipelines = client.projects.inference_pipelines.list(
109
+ project_id=project_id
110
+ )
111
+ return [item.model_dump() for item in inference_pipelines.items]
112
+
113
+
114
+ @mcp.tool()
115
+ def retrieve_inference_pipeline(project_id: str, inference_pipeline_id: str) -> Dict:
116
+ """Retrieve an inference pipeline by ID."""
117
+ inference_pipeline = client.inference_pipelines.retrieve(
118
+ inference_pipeline_id=inference_pipeline_id
119
+ )
120
+ return inference_pipeline.model_dump()
121
+
122
+
123
+ @mcp.tool()
124
+ def create_inference_pipeline(
125
+ project_id: str,
126
+ name: str,
127
+ description: str,
128
+ ) -> Dict:
129
+ """Create a new inference pipeline in project.
130
+
131
+ Args:
132
+ project_id: The ID of the project to create the inference pipeline for.
133
+ name: The name of the inference pipeline to create.
134
+ description: The description of the inference pipeline to create.
135
+ """
136
+ inference_pipeline = client.projects.inference_pipelines.create(
137
+ project_id=project_id,
138
+ name=name,
139
+ description=description,
140
+ )
141
+ return inference_pipeline.model_dump()
142
+
143
+
144
+ # ------------------------------- Test results ------------------------------- #
145
+ @mcp.tool()
146
+ def list_commit_test_results(project_version_id: str) -> List[Dict]:
147
+ """List the test results for a commit.
148
+
149
+ Args:
150
+ project_version_id: The ID of the commit to list the test results for.
151
+ """
152
+ test_results = client.commits.test_results.list(
153
+ project_version_id=project_version_id
154
+ )
155
+ return [item.model_dump() for item in test_results.items]
156
+
157
+
158
+ @mcp.tool()
159
+ def list_inference_pipeline_test_results(inference_pipeline_id: str) -> List[Dict]:
160
+ """List the test results for an inference pipeline."""
161
+ test_results = client.inference_pipelines.test_results.list(
162
+ inference_pipeline_id=inference_pipeline_id
163
+ )
164
+ return [item.model_dump() for item in test_results.items]
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: openlayer-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for the Openlayer platform
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: mcp[cli]>=1.6.0
7
+ Requires-Dist: openlayer>=0.2.0a51
8
+ Description-Content-Type: text/markdown
9
+
10
+ # Openlayer MCP
11
+
12
+ [MCP](https://github.com/modelcontextprotocol) (Model Context Protocol) server for
13
+ the Openlayer platform. This allows MCP clients (such as Cursor, VSCode,
14
+ Claude Desktop, etc.) to interact with the Openlayer platform.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ uv add openlayer-mcp
20
+ ```
21
+ or
22
+
23
+ ```bash
24
+ pip install openlayer-mcp
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ To use the Openlayer MCP server in your IDE or desktop app, you need to add it
30
+ to the MCP configuration file.
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "openlayer": {
36
+ "command": "uvx",
37
+ "args": [
38
+ "openlayer_mcp"
39
+ ],
40
+ "env": {
41
+ "OPENLAYER_API_KEY": "YOUR_OPENLAYER_API_KEY_HERE"
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ You can alternatively run it as a standalone server with:
49
+
50
+ ```bash
51
+ uv run -m openlayer_mcp
52
+ ```
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
@@ -0,0 +1,7 @@
1
+ openlayer_mcp/__init__.py,sha256=5g9AbGPTYtgQsdUeDiNFHzrN78FTUaifHsr_xEhWYH4,121
2
+ openlayer_mcp/__main__.py,sha256=5BjNuyet8AY-POwoF5rGt722rHQ7tJ0Vf0UFUfzzi-I,58
3
+ openlayer_mcp/openlayer_platform.py,sha256=D9IJaz03s9F5OOBnJ1nNP6-T5nWrhVgVDPToE9bI-wE,5031
4
+ openlayer_mcp-0.1.0.dist-info/METADATA,sha256=3OoN_TOCMJSdJ_G7nSboMvlUbNIdIBzEghcxszCKkdQ,1068
5
+ openlayer_mcp-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ openlayer_mcp-0.1.0.dist-info/entry_points.txt,sha256=EYuOoqwfdkIF2Nn0CSQwshxRDaP35DiclnNhjHp_HsI,53
7
+ openlayer_mcp-0.1.0.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
+ openlayer-mcp = openlayer_mcp:main