Test an MCP function
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"serverUrl": "https://mcp.example.com/sse",
"authToken": "Bearer {{secrets.MCP_TOKEN}}",
"functionName": "create_ticket",
"arguments": {
"title": "Printer is broken"
},
"timeOut": 10
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function"
payload = {
"serverUrl": "https://mcp.example.com/sse",
"authToken": "Bearer {{secrets.MCP_TOKEN}}",
"functionName": "create_ticket",
"arguments": { "title": "Printer is broken" },
"timeOut": 10
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
serverUrl: 'https://mcp.example.com/sse',
authToken: 'Bearer {{secrets.MCP_TOKEN}}',
functionName: 'create_ticket',
arguments: {title: 'Printer is broken'},
timeOut: 10
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'serverUrl' => 'https://mcp.example.com/sse',
'authToken' => 'Bearer {{secrets.MCP_TOKEN}}',
'functionName' => 'create_ticket',
'arguments' => [
'title' => 'Printer is broken'
],
'timeOut' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function"
payload := strings.NewReader("{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "success",
"data": {
"success": true,
"result": {
"ticketId": "TICK-123"
},
"error": null,
"executionTime": 812
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Web Tools Routes
Test MCP Function
Runs one function on an MCP server with the arguments you send and returns its result. A failed run (tool error, timeout, unreachable server) still returns 200, with data.success: false and data.error.
POST
/
v2
/
voice-agents
/
web-tool
/
mcp
/
test-function
Test an MCP function
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"serverUrl": "https://mcp.example.com/sse",
"authToken": "Bearer {{secrets.MCP_TOKEN}}",
"functionName": "create_ticket",
"arguments": {
"title": "Printer is broken"
},
"timeOut": 10
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function"
payload = {
"serverUrl": "https://mcp.example.com/sse",
"authToken": "Bearer {{secrets.MCP_TOKEN}}",
"functionName": "create_ticket",
"arguments": { "title": "Printer is broken" },
"timeOut": 10
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
serverUrl: 'https://mcp.example.com/sse',
authToken: 'Bearer {{secrets.MCP_TOKEN}}',
functionName: 'create_ticket',
arguments: {title: 'Printer is broken'},
timeOut: 10
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'serverUrl' => 'https://mcp.example.com/sse',
'authToken' => 'Bearer {{secrets.MCP_TOKEN}}',
'functionName' => 'create_ticket',
'arguments' => [
'title' => 'Printer is broken'
],
'timeOut' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function"
payload := strings.NewReader("{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/web-tool/mcp/test-function")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"serverUrl\": \"https://mcp.example.com/sse\",\n \"authToken\": \"Bearer {{secrets.MCP_TOKEN}}\",\n \"functionName\": \"create_ticket\",\n \"arguments\": {\n \"title\": \"Printer is broken\"\n },\n \"timeOut\": 10\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "success",
"data": {
"success": true,
"result": {
"ticketId": "TICK-123"
},
"error": null,
"executionTime": 812
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Authorizations
Body
application/json
Was this page helpful?