mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
MCP server w.i.p.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
18
examples/mcp_server/test-initialize.sh
Normal file
18
examples/mcp_server/test-initialize.sh
Normal 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
|
||||
14
examples/mcp_server/test-tools-call.sh
Normal file
14
examples/mcp_server/test-tools-call.sh
Normal 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
|
||||
11
examples/mcp_server/test-tools-list.sh
Normal file
11
examples/mcp_server/test-tools-list.sh
Normal 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
|
||||
Reference in New Issue
Block a user