MCP server w.i.p.

This commit is contained in:
Syoyo Fujita
2025-07-11 12:00:47 +09:00
parent 34524d4f21
commit 4e54395b90
5 changed files with 159 additions and 46 deletions

View File

@@ -1,5 +1,11 @@
#include <iostream>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include "prim-types.hh"
#include "tydra/mcp-server.hh"
#include "tydra/command-and-history.hh"
@@ -20,24 +26,28 @@ int main(int argc, char **argv) {
}
std::cout << "is_setr " << parser.is_set("--port") << "\n";
int port = 8085;
double portval;
if (!parser.get("--port", portval)) {
std::cerr << "--port is missing or invalid\n";
return -1;
if (parser.is_set("--port")) {
if (!parser.get("--port", portval)) {
std::cerr << "--port is missing or invalid\n";
return -1;
}
port = int(portval);
}
int port = int(portval);
std::string hostname;
if (!parser.get("--host", hostname)) {
std::cerr << "--host is missing or invalid\n";
return -1;
std::string hostname = "localhost";
if (parser.is_set("--host")) {
if (!parser.get("--host", hostname)) {
std::cerr << "--host is missing or invalid\n";
return -1;
}
}
std::cout << "port " << port << "\n";
std::cout << "hostname " << hostname << "\n";
std::cout << "http://" + hostname << ":" << port << "/mcp" << "\n";
tydra::MCPServer server;
if (!server.init(port, hostname)) {
@@ -45,16 +55,27 @@ int main(int argc, char **argv) {
return -1;
}
bool done =false;
while (!done) {
Layer empty;
tydra::EditHistory hist;
hist.layer = std::move(empty);
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
tydra::HistoryQueue queue;
if (!queue.push(std::move(hist))) {
return -1;
//Layer empty;
//
//tydra::EditHistory hist;
//hist.layer = std::move(empty);
//tydra::HistoryQueue queue;
//if (!queue.push(std::move(hist))) {
// return -1;
//}
}
server.stop();
return 0;

View File

@@ -0,0 +1,18 @@
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"protocolVersion": "2025-03-26",
"capabilities": {
"tools": {}
},
"clientInfo": {
"name": "curl-client",
"version": "1.0.0"
}
},
"id": 1
}' \
http://localhost:8085/mcp

View File

@@ -0,0 +1,14 @@
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "tusdcat",
"arguments": {
"text": "#usda 1.0\n def \"bora\" { }"
},
},
"id": 2
}' \
http://localhost:8085/mcp

View File

@@ -0,0 +1,11 @@
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"params": {
},
},
"id": 2
}' \
http://localhost:8085/mcp