golf-mcp 0.1.11__py3-none-any.whl → 0.1.13__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 golf-mcp might be problematic. Click here for more details.
- golf/__init__.py +1 -1
- golf/auth/__init__.py +38 -26
- golf/auth/api_key.py +16 -23
- golf/auth/helpers.py +68 -54
- golf/auth/oauth.py +340 -277
- golf/auth/provider.py +58 -53
- golf/cli/__init__.py +1 -1
- golf/cli/main.py +209 -87
- golf/commands/__init__.py +1 -1
- golf/commands/build.py +31 -25
- golf/commands/init.py +81 -53
- golf/commands/run.py +30 -15
- golf/core/__init__.py +1 -1
- golf/core/builder.py +493 -362
- golf/core/builder_auth.py +115 -107
- golf/core/builder_telemetry.py +12 -9
- golf/core/config.py +62 -46
- golf/core/parser.py +174 -136
- golf/core/telemetry.py +216 -95
- golf/core/transformer.py +53 -55
- golf/examples/__init__.py +0 -1
- golf/examples/api_key/pre_build.py +2 -2
- golf/examples/api_key/tools/issues/create.py +35 -36
- golf/examples/api_key/tools/issues/list.py +42 -37
- golf/examples/api_key/tools/repos/list.py +50 -29
- golf/examples/api_key/tools/search/code.py +50 -37
- golf/examples/api_key/tools/users/get.py +21 -20
- golf/examples/basic/pre_build.py +4 -4
- golf/examples/basic/prompts/welcome.py +6 -7
- golf/examples/basic/resources/current_time.py +10 -9
- golf/examples/basic/resources/info.py +6 -5
- golf/examples/basic/resources/weather/common.py +16 -10
- golf/examples/basic/resources/weather/current.py +15 -11
- golf/examples/basic/resources/weather/forecast.py +15 -11
- golf/examples/basic/tools/github_user.py +19 -21
- golf/examples/basic/tools/hello.py +10 -6
- golf/examples/basic/tools/payments/charge.py +34 -25
- golf/examples/basic/tools/payments/common.py +8 -6
- golf/examples/basic/tools/payments/refund.py +29 -25
- golf/telemetry/__init__.py +6 -6
- golf/telemetry/instrumentation.py +455 -310
- {golf_mcp-0.1.11.dist-info → golf_mcp-0.1.13.dist-info}/METADATA +1 -1
- golf_mcp-0.1.13.dist-info/RECORD +55 -0
- golf_mcp-0.1.11.dist-info/RECORD +0 -55
- {golf_mcp-0.1.11.dist-info → golf_mcp-0.1.13.dist-info}/WHEEL +0 -0
- {golf_mcp-0.1.11.dist-info → golf_mcp-0.1.13.dist-info}/entry_points.txt +0 -0
- {golf_mcp-0.1.11.dist-info → golf_mcp-0.1.13.dist-info}/licenses/LICENSE +0 -0
- {golf_mcp-0.1.11.dist-info → golf_mcp-0.1.13.dist-info}/top_level.txt +0 -0
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
"""Charge payment tool"""
|
|
2
2
|
|
|
3
3
|
from typing import Annotated
|
|
4
|
+
|
|
4
5
|
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
5
7
|
from .common import payment_client
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class Output(BaseModel):
|
|
9
11
|
"""Response from the charge payment tool."""
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
success: bool
|
|
12
14
|
charge_id: str
|
|
13
15
|
message: str
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
async def charge(
|
|
17
|
-
amount: Annotated[
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
amount: Annotated[
|
|
20
|
+
float,
|
|
21
|
+
Field(
|
|
22
|
+
description="Amount to charge in USD",
|
|
23
|
+
gt=0, # Must be greater than 0
|
|
24
|
+
le=10000, # Maximum charge limit
|
|
25
|
+
),
|
|
26
|
+
],
|
|
27
|
+
card_token: Annotated[
|
|
28
|
+
str,
|
|
29
|
+
Field(
|
|
30
|
+
description="Tokenized payment card identifier",
|
|
31
|
+
pattern=r"^tok_[a-zA-Z0-9]+$", # Validate token format
|
|
32
|
+
),
|
|
33
|
+
],
|
|
34
|
+
description: Annotated[
|
|
35
|
+
str,
|
|
36
|
+
Field(
|
|
37
|
+
description="Optional payment description for the charge", max_length=200
|
|
38
|
+
),
|
|
39
|
+
] = "",
|
|
30
40
|
) -> Output:
|
|
31
41
|
"""Process a payment charge.
|
|
32
|
-
|
|
42
|
+
|
|
33
43
|
This example demonstrates nested directory organization where related tools
|
|
34
44
|
are grouped in subdirectories (tools/payments/charge.py).
|
|
35
|
-
|
|
45
|
+
|
|
36
46
|
The resulting tool ID will be: charge-payments
|
|
37
|
-
|
|
47
|
+
|
|
38
48
|
Args:
|
|
39
49
|
amount: Amount to charge in USD
|
|
40
50
|
card_token: Tokenized payment card
|
|
@@ -43,19 +53,18 @@ async def charge(
|
|
|
43
53
|
# The framework will add a context object automatically
|
|
44
54
|
# You can log using regular print during development
|
|
45
55
|
print(f"Processing charge for ${amount:.2f}...")
|
|
46
|
-
|
|
56
|
+
|
|
47
57
|
# Use the shared payment client from common.py
|
|
48
58
|
charge_result = await payment_client.create_charge(
|
|
49
|
-
amount=amount,
|
|
50
|
-
token=card_token,
|
|
51
|
-
description=description
|
|
59
|
+
amount=amount, token=card_token, description=description
|
|
52
60
|
)
|
|
53
|
-
|
|
61
|
+
|
|
54
62
|
# Create and return the response
|
|
55
63
|
return Output(
|
|
56
64
|
success=True,
|
|
57
65
|
charge_id=charge_result["id"],
|
|
58
|
-
message=f"Successfully charged ${amount:.2f}"
|
|
59
|
-
)
|
|
66
|
+
message=f"Successfully charged ${amount:.2f}",
|
|
67
|
+
)
|
|
68
|
+
|
|
60
69
|
|
|
61
|
-
export = charge
|
|
70
|
+
export = charge
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Payments shared functionality.
|
|
2
2
|
|
|
3
|
-
This common.py file demonstrates the recommended pattern for
|
|
3
|
+
This common.py file demonstrates the recommended pattern for
|
|
4
4
|
sharing functionality across multiple tools in a directory.
|
|
5
5
|
"""
|
|
6
6
|
|
|
@@ -13,17 +13,19 @@ PAYMENT_API_URL = os.environ.get("PAYMENT_API_URL", "https://api.example.com/pay
|
|
|
13
13
|
|
|
14
14
|
class PaymentClient:
|
|
15
15
|
"""Mock payment provider client."""
|
|
16
|
-
|
|
17
|
-
def __init__(
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self, api_key: str = PAYMENT_API_KEY, api_url: str = PAYMENT_API_URL
|
|
19
|
+
) -> None:
|
|
18
20
|
self.api_key = api_key
|
|
19
21
|
self.api_url = api_url
|
|
20
|
-
|
|
22
|
+
|
|
21
23
|
async def create_charge(self, amount: float, token: str, **kwargs):
|
|
22
24
|
"""Create a charge (mock implementation)."""
|
|
23
25
|
# In a real implementation, this would make an API request
|
|
24
26
|
# using the configured API key and URL
|
|
25
27
|
return {"id": f"ch_{int(amount * 100)}_{hash(token) % 10000:04d}"}
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
async def create_refund(self, charge_id: str, amount: float, **kwargs):
|
|
28
30
|
"""Create a refund (mock implementation)."""
|
|
29
31
|
# In a real implementation, this would make an API request
|
|
@@ -31,4 +33,4 @@ class PaymentClient:
|
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
# Create a shared payment client that can be imported by all tools in this directory
|
|
34
|
-
payment_client = PaymentClient()
|
|
36
|
+
payment_client = PaymentClient()
|
|
@@ -1,57 +1,61 @@
|
|
|
1
1
|
"""Refund payment tool"""
|
|
2
2
|
|
|
3
|
-
from typing import Annotated
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
4
5
|
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
5
7
|
from .common import payment_client
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class Output(BaseModel):
|
|
9
11
|
"""Response from the refund payment tool."""
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
success: bool
|
|
12
14
|
refund_id: str
|
|
13
15
|
message: str
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
async def refund(
|
|
17
|
-
charge_id: Annotated[
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
charge_id: Annotated[
|
|
20
|
+
str,
|
|
21
|
+
Field(
|
|
22
|
+
description="The ID of the charge to refund", pattern=r"^ch_[a-zA-Z0-9]+$"
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
amount: Annotated[
|
|
26
|
+
float | None,
|
|
27
|
+
Field(
|
|
28
|
+
description="Amount to refund in USD. If not specified, refunds the full charge amount",
|
|
29
|
+
gt=0,
|
|
30
|
+
default=None,
|
|
31
|
+
),
|
|
32
|
+
] = None,
|
|
33
|
+
reason: Annotated[
|
|
34
|
+
str, Field(description="Reason for the refund", min_length=3, max_length=200)
|
|
35
|
+
] = "Customer request",
|
|
31
36
|
) -> Output:
|
|
32
37
|
"""Process a payment refund.
|
|
33
|
-
|
|
38
|
+
|
|
34
39
|
This example demonstrates nested directory organization where related tools
|
|
35
40
|
are grouped in subdirectories (tools/payments/refund.py).
|
|
36
|
-
|
|
41
|
+
|
|
37
42
|
The resulting tool ID will be: refund-payments
|
|
38
43
|
"""
|
|
39
44
|
# The framework will add a context object automatically
|
|
40
45
|
# You can log using regular print during development
|
|
41
46
|
print(f"Processing refund for charge {charge_id}...")
|
|
42
|
-
|
|
47
|
+
|
|
43
48
|
# Use the shared payment client from common.py
|
|
44
49
|
refund_result = await payment_client.create_refund(
|
|
45
|
-
charge_id=charge_id,
|
|
46
|
-
amount=amount,
|
|
47
|
-
reason=reason
|
|
50
|
+
charge_id=charge_id, amount=amount, reason=reason
|
|
48
51
|
)
|
|
49
|
-
|
|
52
|
+
|
|
50
53
|
# Create and return the response
|
|
51
54
|
return Output(
|
|
52
55
|
success=True,
|
|
53
56
|
refund_id=refund_result["id"],
|
|
54
|
-
message=f"Successfully refunded charge {charge_id}"
|
|
57
|
+
message=f"Successfully refunded charge {charge_id}",
|
|
55
58
|
)
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
|
|
61
|
+
export = refund
|
golf/telemetry/__init__.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"""Golf telemetry module for OpenTelemetry instrumentation."""
|
|
2
2
|
|
|
3
3
|
from golf.telemetry.instrumentation import (
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
get_tracer,
|
|
5
|
+
init_telemetry,
|
|
6
6
|
instrument_prompt,
|
|
7
|
+
instrument_resource,
|
|
8
|
+
instrument_tool,
|
|
7
9
|
telemetry_lifespan,
|
|
8
|
-
init_telemetry,
|
|
9
|
-
get_tracer,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
__all__ = [
|
|
13
13
|
"instrument_tool",
|
|
14
|
-
"instrument_resource",
|
|
14
|
+
"instrument_resource",
|
|
15
15
|
"instrument_prompt",
|
|
16
16
|
"telemetry_lifespan",
|
|
17
17
|
"init_telemetry",
|
|
18
18
|
"get_tracer",
|
|
19
|
-
]
|
|
19
|
+
]
|