mostlyai-mock 0.0.8__py3-none-any.whl → 0.0.9__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.
- mostlyai/mock/__init__.py +1 -1
- mostlyai/mock/mcp_server.py +85 -0
- {mostlyai_mock-0.0.8.dist-info → mostlyai_mock-0.0.9.dist-info}/METADATA +1 -2
- mostlyai_mock-0.0.9.dist-info/RECORD +8 -0
- mostlyai_mock-0.0.9.dist-info/entry_points.txt +2 -0
- mostlyai/mock/mcp.py +0 -46
- mostlyai_mock-0.0.8.dist-info/RECORD +0 -8
- mostlyai_mock-0.0.8.dist-info/entry_points.txt +0 -2
- {mostlyai_mock-0.0.8.dist-info → mostlyai_mock-0.0.9.dist-info}/WHEEL +0 -0
- {mostlyai_mock-0.0.8.dist-info → mostlyai_mock-0.0.9.dist-info}/licenses/LICENSE +0 -0
mostlyai/mock/__init__.py
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
import os
|
2
|
+
import tempfile
|
3
|
+
import zipfile
|
4
|
+
|
5
|
+
import requests
|
6
|
+
from fastmcp import Context, FastMCP
|
7
|
+
|
8
|
+
from mostlyai import mock
|
9
|
+
|
10
|
+
SAMPLE_MOCK_TOOL_DESCRIPTION = f"""
|
11
|
+
It is proxy to the `mostlyai.mock.sample` function.
|
12
|
+
|
13
|
+
This function returns an URL to the generated CSV bundle (as ZIP file).
|
14
|
+
Print this URL in Markdown format, so user can easily download the data.
|
15
|
+
|
16
|
+
What comes after the `=============================` is the documentation of the `mostlyai.mock.sample` function.
|
17
|
+
|
18
|
+
=============================
|
19
|
+
{mock.sample.__doc__}
|
20
|
+
"""
|
21
|
+
|
22
|
+
mcp = FastMCP(name="MostlyAI Mock MCP Server")
|
23
|
+
|
24
|
+
|
25
|
+
def _upload_to_0x0st(data: dict) -> str:
|
26
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
27
|
+
zip_path = os.path.join(temp_dir, "mock_data.zip")
|
28
|
+
with zipfile.ZipFile(zip_path, "w") as zip_file:
|
29
|
+
for table_name, df in data.items():
|
30
|
+
csv_path = os.path.join(temp_dir, f"{table_name}.csv")
|
31
|
+
df.to_csv(csv_path, index=False)
|
32
|
+
zip_file.write(csv_path, arcname=f"{table_name}.csv")
|
33
|
+
|
34
|
+
with open(zip_path, "rb") as f:
|
35
|
+
response = requests.post(
|
36
|
+
"https://0x0.st",
|
37
|
+
files={"file": f},
|
38
|
+
data={"expires": "24", "secret": ""},
|
39
|
+
headers={"User-Agent": "MockData/1.0"},
|
40
|
+
)
|
41
|
+
|
42
|
+
if response.status_code == 200:
|
43
|
+
url = response.text.strip()
|
44
|
+
return url
|
45
|
+
else:
|
46
|
+
raise Exception(f"Failed to upload ZIP: HTTP {response.status_code}")
|
47
|
+
|
48
|
+
|
49
|
+
@mcp.tool(description=SAMPLE_MOCK_TOOL_DESCRIPTION)
|
50
|
+
def sample_mock_data(
|
51
|
+
*,
|
52
|
+
tables: dict[str, dict],
|
53
|
+
sample_size: int,
|
54
|
+
model: str = "openai/gpt-4.1-nano",
|
55
|
+
api_key: str | None = None,
|
56
|
+
temperature: float = 1.0,
|
57
|
+
top_p: float = 0.95,
|
58
|
+
ctx: Context,
|
59
|
+
) -> str:
|
60
|
+
# Notes:
|
61
|
+
# 1. Returning DataFrames directly results in converting them into truncated string.
|
62
|
+
# 2. The logs / progress bars are not propagated to the MCP Client. There is a dedicated API to do that (e.g. `ctx.info(...)`)
|
63
|
+
# 3. MCP Server inherits only selected environment variables (PATH, USER...); one way to pass LLM keys is through client configuration (`mcpServers->env`)
|
64
|
+
# 4. Some MCP Clients, e.g. Cursor, do not like Unions or Optionals in type hints
|
65
|
+
ctx.info(f"Generating mock data for `{len(tables)}` tables")
|
66
|
+
data = mock.sample(
|
67
|
+
tables=tables,
|
68
|
+
sample_size=sample_size,
|
69
|
+
model=model,
|
70
|
+
api_key=api_key,
|
71
|
+
temperature=temperature,
|
72
|
+
top_p=top_p,
|
73
|
+
return_type="dict",
|
74
|
+
)
|
75
|
+
ctx.info(f"Generated mock data for `{len(tables)}` tables")
|
76
|
+
url = _upload_to_0x0st(data)
|
77
|
+
return url
|
78
|
+
|
79
|
+
|
80
|
+
def main():
|
81
|
+
mcp.run(transport="stdio")
|
82
|
+
|
83
|
+
|
84
|
+
if __name__ == "__main__":
|
85
|
+
main()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mostlyai-mock
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.9
|
4
4
|
Summary: Synthetic Mock Data
|
5
5
|
Project-URL: homepage, https://github.com/mostly-ai/mostlyai-mock
|
6
6
|
Project-URL: repository, https://github.com/mostly-ai/mostlyai-mock
|
@@ -30,7 +30,6 @@ Requires-Dist: numpy>=1.26.3
|
|
30
30
|
Requires-Dist: pandas>=2.0.0
|
31
31
|
Requires-Dist: pyarrow>=14.0.0
|
32
32
|
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
33
|
-
Requires-Dist: typer<1.0.0,>=0.9.0
|
34
33
|
Description-Content-Type: text/markdown
|
35
34
|
|
36
35
|
# Synthetic Mock Data 🔮
|
@@ -0,0 +1,8 @@
|
|
1
|
+
mostlyai/mock/__init__.py,sha256=jObvPbThXtHSUyMozHQZdSsgvR_fiii7gcPNjnBx0WM,714
|
2
|
+
mostlyai/mock/core.py,sha256=p5VAsRppzAc4P8FqKEunfQ3cPjImUU2cEc6yqHJVhMg,29884
|
3
|
+
mostlyai/mock/mcp_server.py,sha256=0oyv-7M2Cm9a7JdrMKwHSb3nucPW1J2N6YiYASboAbM,2741
|
4
|
+
mostlyai_mock-0.0.9.dist-info/METADATA,sha256=plPb0H5ilUw9_wzB8i5s0Rmw4W0VXWjmx7NiaS7hEGk,11380
|
5
|
+
mostlyai_mock-0.0.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
+
mostlyai_mock-0.0.9.dist-info/entry_points.txt,sha256=XDbppUIAaCWW0nresVep8zb71pkzZuFA16jCBHq8CU8,61
|
7
|
+
mostlyai_mock-0.0.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
+
mostlyai_mock-0.0.9.dist-info/RECORD,,
|
mostlyai/mock/mcp.py
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
|
3
|
-
import pandas as pd
|
4
|
-
from fastmcp import Context, FastMCP
|
5
|
-
|
6
|
-
from mostlyai import mock
|
7
|
-
|
8
|
-
mcp = FastMCP(name="MostlyAI Mock MCP Server")
|
9
|
-
|
10
|
-
|
11
|
-
@mcp.tool(description=mock.sample.__doc__)
|
12
|
-
def sample_mock_data(
|
13
|
-
*,
|
14
|
-
tables: dict[str, dict],
|
15
|
-
sample_size: int,
|
16
|
-
model: str = "openai/gpt-4.1-nano",
|
17
|
-
api_key: str | None = None,
|
18
|
-
temperature: float = 1.0,
|
19
|
-
top_p: float = 0.95,
|
20
|
-
ctx: Context,
|
21
|
-
) -> str:
|
22
|
-
# Notes:
|
23
|
-
# 1. Returning DataFrames directly results in converting them into truncated string.
|
24
|
-
# 2. The logs / progress bars are not propagated to the MCP Client. There is a dedicated API to do that (e.g. `ctx.info(...)`)
|
25
|
-
# 3. MCP Server inherits only selected environment variables (PATH, USER...); one way to pass LLM keys is through client configuration (`mcpServers->env`)
|
26
|
-
# 4. Some MCP Clients, e.g. Cursor, do not like Unions or Optionals in type hints
|
27
|
-
ctx.info(f"Generating mock data for `{len(tables)}` tables")
|
28
|
-
data = mock.sample(
|
29
|
-
tables=tables,
|
30
|
-
sample_size=sample_size,
|
31
|
-
model=model,
|
32
|
-
api_key=api_key,
|
33
|
-
temperature=temperature,
|
34
|
-
top_p=top_p,
|
35
|
-
return_type="dict",
|
36
|
-
)
|
37
|
-
ctx.info(f"Generated mock data for `{len(tables)}` tables")
|
38
|
-
return {k: v.to_dict(orient="records") for k, v in data.items()}
|
39
|
-
|
40
|
-
|
41
|
-
def main():
|
42
|
-
mcp.run(transport="stdio")
|
43
|
-
|
44
|
-
|
45
|
-
if __name__ == "__main__":
|
46
|
-
main()
|
@@ -1,8 +0,0 @@
|
|
1
|
-
mostlyai/mock/__init__.py,sha256=APjm2I3FljM9lFH6sdbIYyh5eC-8KTOuDKG_KXGXaHQ,714
|
2
|
-
mostlyai/mock/core.py,sha256=p5VAsRppzAc4P8FqKEunfQ3cPjImUU2cEc6yqHJVhMg,29884
|
3
|
-
mostlyai/mock/mcp.py,sha256=Ryp9aXBzGzHRFVwNt1gftrYlhYcQifCNhjRgn-iX7zc,1400
|
4
|
-
mostlyai_mock-0.0.8.dist-info/METADATA,sha256=DCO1oHuu6tOHGog--wEloM31HP0tGbztZP4F1YyzKzk,11415
|
5
|
-
mostlyai_mock-0.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
mostlyai_mock-0.0.8.dist-info/entry_points.txt,sha256=77Swgr1rLuEmeCNOiwoUyKd128_c1Q5l88pj_7JVKaY,54
|
7
|
-
mostlyai_mock-0.0.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
-
mostlyai_mock-0.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|