fastmcp-tools-http 0.1.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.
- fastmcp_tools_http-0.1.0/PKG-INFO +7 -0
- fastmcp_tools_http-0.1.0/pyproject.toml +22 -0
- fastmcp_tools_http-0.1.0/setup.cfg +4 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http/__init__.py +5 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http/fetch_url.py +28 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http/post_json.py +34 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/PKG-INFO +7 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/SOURCES.txt +10 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/dependency_links.txt +1 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/entry_points.txt +2 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/requires.txt +1 -0
- fastmcp_tools_http-0.1.0/src/fastmcp_tools_http.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fastmcp-tools-http"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "HTTP tools for fastmcp-server"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = ["requests>=2.31"]
|
|
12
|
+
|
|
13
|
+
[project.entry-points."fastmcp_tools"]
|
|
14
|
+
http = "fastmcp_tools_http"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
where = ["src"]
|
|
18
|
+
include = ["fastmcp_tools_http*"]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.package-data]
|
|
22
|
+
"fastmcp_tools_http" = ["*.py"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Fetch content from a URL.
|
|
2
|
+
|
|
3
|
+
Requires: requests
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__tags__ = ["http", "read"]
|
|
7
|
+
__timeout__ = 30.0
|
|
8
|
+
__max_output_size_kb__ = 500
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def fetch_url(
|
|
12
|
+
url: str,
|
|
13
|
+
method: str = "GET",
|
|
14
|
+
headers: str = "",
|
|
15
|
+
) -> str:
|
|
16
|
+
"""Fetch content from a URL. Headers as 'Key: Value' lines."""
|
|
17
|
+
import requests
|
|
18
|
+
|
|
19
|
+
parsed_headers = {}
|
|
20
|
+
if headers:
|
|
21
|
+
for line in headers.strip().split("\n"):
|
|
22
|
+
if ":" in line:
|
|
23
|
+
key, value = line.split(":", 1)
|
|
24
|
+
parsed_headers[key.strip()] = value.strip()
|
|
25
|
+
|
|
26
|
+
resp = requests.request(method, url, headers=parsed_headers, timeout=15)
|
|
27
|
+
|
|
28
|
+
return f"Status: {resp.status_code}\n\n{resp.text}"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""POST JSON data to a URL.
|
|
2
|
+
|
|
3
|
+
Requires: requests
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__tags__ = ["http", "write"]
|
|
7
|
+
__timeout__ = 30.0
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def post_json(
|
|
11
|
+
url: str,
|
|
12
|
+
data: str,
|
|
13
|
+
headers: str = "",
|
|
14
|
+
) -> str:
|
|
15
|
+
"""POST JSON data to a URL. Data should be a valid JSON string."""
|
|
16
|
+
import json
|
|
17
|
+
|
|
18
|
+
import requests
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
payload = json.loads(data)
|
|
22
|
+
except json.JSONDecodeError as e:
|
|
23
|
+
return f"Error: Invalid JSON data: {e}"
|
|
24
|
+
|
|
25
|
+
parsed_headers = {"Content-Type": "application/json"}
|
|
26
|
+
if headers:
|
|
27
|
+
for line in headers.strip().split("\n"):
|
|
28
|
+
if ":" in line:
|
|
29
|
+
key, value = line.split(":", 1)
|
|
30
|
+
parsed_headers[key.strip()] = value.strip()
|
|
31
|
+
|
|
32
|
+
resp = requests.post(url, json=payload, headers=parsed_headers, timeout=15)
|
|
33
|
+
|
|
34
|
+
return f"Status: {resp.status_code}\n\n{resp.text}"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
src/fastmcp_tools_http/__init__.py
|
|
3
|
+
src/fastmcp_tools_http/fetch_url.py
|
|
4
|
+
src/fastmcp_tools_http/post_json.py
|
|
5
|
+
src/fastmcp_tools_http.egg-info/PKG-INFO
|
|
6
|
+
src/fastmcp_tools_http.egg-info/SOURCES.txt
|
|
7
|
+
src/fastmcp_tools_http.egg-info/dependency_links.txt
|
|
8
|
+
src/fastmcp_tools_http.egg-info/entry_points.txt
|
|
9
|
+
src/fastmcp_tools_http.egg-info/requires.txt
|
|
10
|
+
src/fastmcp_tools_http.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.31
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fastmcp_tools_http
|