You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewMcpError(ErrorCode.InvalidParams,`Invalid host format. The 'host' argument must be a valid URL starting with http:// or https://, e.g. "https://example.com" or "http://localhost:3001/api/v1". Received: "${args.host}"`);
153
+
}
154
+
}
136
155
137
156
returntrue;
138
157
};
@@ -353,10 +372,11 @@ class RestTester {
353
372
// Ensure endpoint starts with / and remove any trailing slashes
Copy file name to clipboardExpand all lines: src/resources/examples.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,29 @@
1
1
# REST API Testing Examples
2
2
3
-
⚠️ IMPORTANT: Only provide the endpoint path - do not include full URLs. Your path will be automatically resolved to the full URL.
3
+
⚠️ IMPORTANT:
4
+
- Only provide the endpoint path in the `endpoint` argument—do not include full URLs. Your path will be automatically resolved to the full URL using the configured base URL or the optional `host` argument.
5
+
- To override the base URL for a single request, use the optional `host` argument. This must be a valid URL starting with `http://` or `https://`, and may include a path (trailing slashes will be removed).
4
6
5
7
For example, if the base URL is `http://localhost:3000`:
6
8
✅ Correct: `"/api/users"` → Resolves to: `http://localhost:3000/api/users`
7
9
❌ Incorrect: `"http://localhost:3000/api/users"` or `"www.example.com/api/users"`
8
10
11
+
If you use a `host` argument:
12
+
✅ Correct: `"host": "https://api.example.com/v1", "endpoint": "/users"` → Resolves to: `https://api.example.com/v1/users`
13
+
9
14
## Basic GET Request
10
15
```typescript
11
16
use_mcp_tool('rest-api', 'test_request', {
12
17
"method": "GET",
13
-
"endpoint": "/users"// Will be appended to REST_BASE_URL
18
+
"endpoint": "/users"// Will be appended to REST_BASE_URL or 'host' if provided
14
19
});
15
20
```
16
21
17
22
## GET with Query Parameters
18
23
```typescript
19
24
use_mcp_tool('rest-api', 'test_request', {
20
25
"method": "GET",
21
-
"endpoint": "/users?role=admin&status=active"
26
+
"endpoint": "/users?role=admin&status=active"// Always a path, not a full URL
You can override the default base URL for a single request by providing a `host` argument. This must be a valid URL starting with `http://` or `https://`, and may include a path (trailing slashes will be removed).
76
+
77
+
```typescript
78
+
use_mcp_tool('rest-api', 'test_request', {
79
+
"method": "GET",
80
+
"endpoint": "/users",
81
+
"host": "https://api.example.com/v1"// The request will go to https://api.example.com/v1/users
82
+
});
83
+
```
84
+
85
+
- The `host` argument must include the protocol (http or https).
86
+
- If a path is included, any trailing slash will be removed.
87
+
- If `host` is invalid, you will receive a clear error message.
88
+
- The `endpoint` argument must always be a path, never a full URL.
89
+
69
90
## Changing Base URL
70
-
If you need to test against a different base URL, update the base URL configuration rather than including the full URL in the endpoint parameter.
91
+
If you need to test against a different base URL for all requests, update the base URL configuration rather than including the full URL in the endpoint parameter. For a single request, use the `host` argument as shown above.
71
92
72
93
Example:
73
94
```bash
@@ -78,3 +99,6 @@ Example:
78
99
# 1. Update the base URL configuration to: https://api.example.com
79
100
# 2. Then use just the path:
80
101
✅ "endpoint": "/users"# This will resolve to: https://api.example.com/users
102
+
# Or, for a single request:
103
+
✅ "host": "https://api.example.com", "endpoint": "/users"# This will resolve to: https://api.example.com/users
0 commit comments