invoice-reminder-api-mcp 1.0.0__tar.gz

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,10 @@
1
+ .env.local
2
+ .env
3
+ node_modules
4
+ .venv
5
+ .DS_Store
6
+ __pycache__
7
+ *.pyc
8
+ dist
9
+ build
10
+ .next
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.5
2
+ Name: invoice-reminder-api-mcp
3
+ Version: 1.0.0
4
+ Summary: Überfällige Rechnungen automatisch per Agenten-Call nachfassen
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: httpx>=0.27.0
7
+ Requires-Dist: mcp<2.0.0,>=1.4.0
8
+ Requires-Dist: pydantic>=2.7.0
@@ -0,0 +1,104 @@
1
+ """Generiert von ap10-multi-channel (WP 6.1 Payload 2) — eigenständiges MCP-PyPI-Paket."""
2
+ import json
3
+ import os
4
+
5
+ import httpx
6
+ from mcp.server import Server
7
+ from mcp.types import Tool, TextContent
8
+ from pydantic import BaseModel, ConfigDict, Field
9
+
10
+
11
+ class ExecutionRequestSchema(BaseModel):
12
+ model_config = ConfigDict(extra="forbid", str_strip_whitespace=True, validate_assignment=True)
13
+ target_url: str = Field(..., description="Ziel-URL/-Ressource des Kernflows.")
14
+
15
+
16
+ mcp = Server("invoice-reminder-api")
17
+
18
+
19
+ def resilient_mcp_argument_mapper(raw_arguments: dict) -> dict:
20
+ """
21
+ Transformiert leicht abweichende Agenten-Inputs vor dem Pydantic extra='forbid' Gate,
22
+ um HTTP 422 Abbrüche bei abweichenden MCP-Client-Formaten zu verhindern.
23
+ """
24
+ mapped = raw_arguments.copy()
25
+ if "target_urls" in mapped and isinstance(mapped["target_urls"], str):
26
+ mapped["target_urls"] = [mapped["target_urls"]]
27
+ if "url" in mapped and "target_url" not in mapped:
28
+ mapped["target_url"] = mapped.pop("url")
29
+ return mapped
30
+
31
+
32
+ @mcp.list_tools()
33
+ async def list_tools() -> list[Tool]:
34
+ return [
35
+ Tool(
36
+ name="execute_invoice_reminder_api",
37
+ description="Überfällige Rechnungen automatisch per Agenten-Call nachfassen",
38
+ inputSchema=ExecutionRequestSchema.model_json_schema(),
39
+ )
40
+ ]
41
+
42
+
43
+ @mcp.call_tool()
44
+ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
45
+ if name != "execute_invoice_reminder_api":
46
+ raise ValueError(f"Unbekanntes Tool: {name}")
47
+
48
+ normalized_arguments = resilient_mcp_argument_mapper(arguments)
49
+ validated_args = ExecutionRequestSchema(**normalized_arguments)
50
+
51
+ base_url = os.environ.get("OHJA_MCP_BASE_URL")
52
+ if not base_url:
53
+ return [
54
+ TextContent(
55
+ type="text",
56
+ text=json.dumps(
57
+ {
58
+ "error": "MCP_SERVER_MISCONFIGURED",
59
+ "message": "OHJA_MCP_BASE_URL ist nicht gesetzt.",
60
+ }
61
+ ),
62
+ )
63
+ ]
64
+
65
+ headers = {"Content-Type": "application/json"}
66
+ api_key = os.environ.get("OHJA_API_KEY")
67
+ if api_key:
68
+ headers["X-API-KEY"] = api_key
69
+
70
+ try:
71
+ async with httpx.AsyncClient(timeout=30.0) as client:
72
+ response = await client.post(
73
+ f"{base_url}/v1/execute",
74
+ json=validated_args.model_dump(),
75
+ headers=headers,
76
+ )
77
+ except httpx.HTTPError as exc:
78
+ return [
79
+ TextContent(
80
+ type="text",
81
+ text=json.dumps({"error": "MCP_UPSTREAM_UNREACHABLE", "message": str(exc)}),
82
+ )
83
+ ]
84
+
85
+ if response.status_code == 200:
86
+ return [TextContent(type="text", text=response.json()["data"]["result"])]
87
+
88
+ return [TextContent(type="text", text=json.dumps(response.json()["detail"]))]
89
+
90
+
91
+ def main() -> None:
92
+ import asyncio
93
+
94
+ from mcp.server.stdio import stdio_server
95
+
96
+ async def _run_stdio() -> None:
97
+ async with stdio_server() as (read_stream, write_stream):
98
+ await mcp.run(read_stream, write_stream, mcp.create_initialization_options())
99
+
100
+ asyncio.run(_run_stdio())
101
+
102
+
103
+ if __name__ == "__main__":
104
+ main()
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "invoice-reminder-api-mcp"
3
+ version = "1.0.0"
4
+ description = "Überfällige Rechnungen automatisch per Agenten-Call nachfassen"
5
+ requires-python = ">=3.10"
6
+ dependencies = [
7
+ "mcp>=1.4.0,<2.0.0",
8
+ "httpx>=0.27.0",
9
+ "pydantic>=2.7.0",
10
+ ]
11
+
12
+ [project.scripts]
13
+ "invoice-reminder-api-mcp" = "mcp_server:main"
14
+
15
+ [build-system]
16
+ requires = ["hatchling"]
17
+ build-backend = "hatchling.build"
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ include = ["mcp_server.py"]
21
+
22
+ [tool.uv]
23
+ constraint-dependencies = ["cryptography<47"]