if it helps anyone, this is how i did my setup:
first i made a publicly available API endpoint, that gets used by AI assistant to get the MCP config, like:
mydomain/api/tawkto/mcp
Tawkto will call this endpoint to obtain the MCP config adhering to MCP standard. There are some other specifics that made it work for me, best shown by code of the /mcp endpoint:
public function mcpResponse(){
if (!empty($this->body)
&& isset($this->body['jsonrpc'])
&& isset($this->body['id'])
&& isset($this->body['method'])
&& $this->body['method'] === 'tools/list'
) {
$response = [
"jsonrpc" => $this->body['jsonrpc'],
"id" => $this->body['id'],
"result" => [
"tools" => [
[
'name' => 'myEndpoint',
'description' => 'details of my endpoint',
'inputSchema' => [
'type' => 'object',
'properties' => [
'hash' => [
'type' => 'string',
'description' => 'auth hash token.'
],
],
'required' => [
'hash',
]
]
],
[
'name' => 'myEndpoint2',
'description' => 'description of endpoint2',
'inputSchema' => [
'type' => 'object',
'properties' => [
'hash' => [
'type' => 'string'
'description' => 'auth hash token.'
],
'input_field_that_i_need' => [
'type' => 'string',
'description' => 'unique string for this endpoint.'
]
],
'required' => [
'hash',
'input_field_that_i_need'
]
]
]
]
]
];
$this->response->headers('Content-Type', 'application/json');
return $this->response->body(json_encode($response));
}
}
then in tawkto i made a new MCP entry… filled the name, description, label and for the url of my api, example mydomain/api/tawkto/mcp.
Then refresh the tool and so tawkto did request to my mcp endpoint to get the config, which is last step.
I also have auth token in my API, in bearer token for authentication. I added it and it gets written in the request headers in HTTP_AUTHORIZATION when tawkto calls your API endpoints… this is how i extracted it:
$authorization = null;
if (isset($_SERVER['Authorization'])) {
$authorization = trim($_SERVER["Authorization"]);
} else if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
$authorization = trim($_SERVER["HTTP_AUTHORIZATION"]);
}
$this->hash = null;
if (!empty($authorization)) {
if (preg_match('/Bearer\s(\S+)/', $authorization, $matches)) {
$this->hash = $matches[1];
}
}