Skip to content

Commit 9ea6ca9

Browse files
authored
[chore] updating example to show that you can use custom base url during call
1 parent c801d9e commit 9ea6ca9

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/resources/examples.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
# REST API Testing Examples
22

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).
46

57
For example, if the base URL is `http://localhost:3000`:
68
✅ Correct: `"/api/users"` → Resolves to: `http://localhost:3000/api/users`
79
❌ Incorrect: `"http://localhost:3000/api/users"` or `"www.example.com/api/users"`
810

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+
914
## Basic GET Request
1015
```typescript
1116
use_mcp_tool('rest-api', 'test_request', {
1217
"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
1419
});
1520
```
1621

1722
## GET with Query Parameters
1823
```typescript
1924
use_mcp_tool('rest-api', 'test_request', {
2025
"method": "GET",
21-
"endpoint": "/users?role=admin&status=active"
26+
"endpoint": "/users?role=admin&status=active" // Always a path, not a full URL
2227
});
2328
```
2429

@@ -66,8 +71,24 @@ use_mcp_tool('rest-api', 'test_request', {
6671
});
6772
```
6873

74+
## Using the Optional `host` Argument
75+
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+
6990
## 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.
7192

7293
Example:
7394
```bash
@@ -78,3 +99,6 @@ Example:
7899
# 1. Update the base URL configuration to: https://api.example.com
79100
# 2. Then use just the path:
80101
"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
104+
```

0 commit comments

Comments
 (0)