forked from community-shaders/skyrim-community-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(remote-control): add MCP server core feature #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
275cf6d
feat(remote-control): add MCP server core feature
alandtse eaa6877
feat(remote-control): add list_features tool
alandtse 8abac4c
feat(remote-control): add get_feature_settings tool
alandtse 2bc690a
feat(remote-control): add toggle_feature tool
alandtse 89d1ded
feat(remote-control): add set_feature_settings tool
alandtse 4e2b3d6
feat(remote-control): add reset_feature_settings tool
alandtse 43fdba7
feat(remote-control): add console tool
alandtse 390b25a
feat(remote-control): add capture tool (kind-dispatched)
alandtse aac30ad
feat(remote-control): add connected-clients ImGui table
alandtse 2dc74ff
feat(remote-control): add abtest tool (action-dispatched)
alandtse 94e99df
fix(remote-control): add feature includes for capture tool
alandtse d47e405
refactor(remote-control): consolidate to 5 tools
alandtse 675e8a3
fix(remote-control): enforce loopback-only bind + clamp port
alandtse 4684e2c
fix(remote-control): clarify loopback-only UI + guard cmake patch
alandtse a8a2d96
fix(remote-control): race-free frameCount + IPv6 URL + tool docs
alandtse f969628
fix(remote-control): add explicit STL headers; CONFIGURE_DEPENDS on h…
alandtse 65b7545
fix(remote-control): marshal mutations to main thread; tighten loopback
alandtse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Build cpp-mcp (https://github.com/hkr04/cpp-mcp) from its vendored | ||
| # submodule as a static library target. Upstream has no install rules | ||
| # (PR #12 still open), so we drive its build ourselves — same pattern | ||
| # we use for FidelityFX-SDK and Streamline. | ||
| # | ||
| # Only the server-side translation units are compiled; the bundled | ||
| # stdio/SSE *client* implementations are intentionally omitted because | ||
| # we are exclusively a server. | ||
| # | ||
| # nlohmann_json ABI alignment: | ||
| # cpp-mcp vendors nlohmann_json 3.11.3 in extern/cpp-mcp/common/json.hpp, | ||
| # while vcpkg ships 3.12.0. Both versions wrap their public API in an | ||
| # ABI-versioned inline namespace (`nlohmann::json_abi_v3_11_3` vs | ||
| # `nlohmann::json_abi_v3_12_0`), so even though both files share the | ||
| # same include guard (INCLUDE_NLOHMANN_JSON_HPP_), the symbol names | ||
| # differ. If cpp-mcp's own TUs picked up the vendored copy and our | ||
| # consumers picked up vcpkg's, `mcp::server::set_capabilities` and | ||
| # `register_tool` would link-fail (LNK2001) with two different | ||
| # ABI-tagged signatures. | ||
| # | ||
| # Fix: patch mcp_message.h at configure time to use | ||
| # `#include <nlohmann/json.hpp>` instead of `#include "json.hpp"`. | ||
| # The patched copy is written to a build-tree mirror; the submodule | ||
| # stays clean. Both cpp-mcp's own compilation and every consumer | ||
| # then resolve to vcpkg's 3.12.0 → single ABI namespace, symbols | ||
| # match, linker happy. | ||
|
|
||
| set(CPP_MCP_DIR "${CMAKE_SOURCE_DIR}/extern/cpp-mcp") | ||
| set(CPP_MCP_PATCHED_INC "${CMAKE_BINARY_DIR}/cpp-mcp-patched/include") | ||
|
|
||
| if(NOT EXISTS "${CPP_MCP_DIR}/src/mcp_server.cpp") | ||
| message(FATAL_ERROR | ||
| "cpp-mcp submodule missing. Run:\n" | ||
| " git submodule update --init --recursive extern/cpp-mcp") | ||
| endif() | ||
|
|
||
| find_package(Threads REQUIRED) | ||
| find_package(nlohmann_json CONFIG REQUIRED) | ||
|
|
||
| # Patch mcp_message.h to use vcpkg nlohmann_json (see header comment). | ||
| # All other cpp-mcp headers are copied verbatim into the patched mirror | ||
| # so they live next to the patched header and find each other. | ||
| file(MAKE_DIRECTORY "${CPP_MCP_PATCHED_INC}") | ||
| file(GLOB _cpp_mcp_headers CONFIGURE_DEPENDS "${CPP_MCP_DIR}/include/*.h") | ||
| foreach(_hdr IN LISTS _cpp_mcp_headers) | ||
| get_filename_component(_name "${_hdr}" NAME) | ||
| file(READ "${_hdr}" _content) | ||
| if(_name STREQUAL "mcp_message.h") | ||
| # Fail fast if the expected include vanishes upstream — otherwise the | ||
| # ABI mismatch would silently come back and only surface as an LNK2001 | ||
| # well into the link step. | ||
| string(FIND "${_content}" "#include \"json.hpp\"" _json_inc_pos) | ||
| if(_json_inc_pos EQUAL -1) | ||
| message(FATAL_ERROR | ||
| "cpp-mcp: expected `#include \"json.hpp\"` in mcp_message.h " | ||
| "but did not find it. Upstream may have changed the include; " | ||
| "review cmake/cpp-mcp.cmake and adjust the patch (see header " | ||
| "comment for the ABI-alignment rationale).") | ||
| endif() | ||
| string(REPLACE | ||
| "#include \"json.hpp\"" | ||
| "#include <nlohmann/json.hpp>" | ||
| _content "${_content}") | ||
| endif() | ||
| file(WRITE "${CPP_MCP_PATCHED_INC}/${_name}" "${_content}") | ||
| endforeach() | ||
|
|
||
| add_library(cpp-mcp STATIC | ||
| "${CPP_MCP_DIR}/src/mcp_message.cpp" | ||
| "${CPP_MCP_DIR}/src/mcp_resource.cpp" | ||
| "${CPP_MCP_DIR}/src/mcp_server.cpp" | ||
| "${CPP_MCP_DIR}/src/mcp_tool.cpp" | ||
| ) | ||
|
|
||
| # Order matters: patched mirror first so its mcp_message.h wins over the | ||
| # submodule's. `common/` is still needed for httplib.h (no ABI issue | ||
| # there — it's not shared with any vcpkg dep). | ||
| target_include_directories(cpp-mcp | ||
| PUBLIC "${CPP_MCP_PATCHED_INC}" | ||
| "${CPP_MCP_DIR}/common" | ||
| ) | ||
|
|
||
| target_compile_features(cpp-mcp PUBLIC cxx_std_17) | ||
|
|
||
| target_compile_definitions(cpp-mcp PUBLIC | ||
| MCP_MAX_SESSIONS=10 | ||
| MCP_SESSION_TIMEOUT=30 | ||
| # cpp-mcp's vendored cpp-httplib pulls in <winsock2.h>. Skyrim/CLib's | ||
| # transitive <Windows.h> defaults to the legacy <winsock.h>, which | ||
| # conflicts (redefinition of sockaddr, WSAData, etc.). Tell Windows | ||
| # headers to skip the legacy winsock so winsock2.h is the only one | ||
| # in the build. PUBLIC so it propagates to every TU that links | ||
| # cpp-mcp (including the PCH compilation of CommunityShaders). | ||
| _WINSOCKAPI_ | ||
| ) | ||
|
|
||
| target_link_libraries(cpp-mcp PUBLIC | ||
| Threads::Threads | ||
| nlohmann_json::nlohmann_json | ||
| ) | ||
|
|
||
| if(MSVC) | ||
| target_compile_options(cpp-mcp PRIVATE /utf-8 /bigobj /W0) | ||
| target_compile_definitions(cpp-mcp PRIVATE _CRT_SECURE_NO_WARNINGS) | ||
| endif() | ||
|
|
||
| set_target_properties(cpp-mcp PROPERTIES FOLDER "extern") | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [Info] | ||
| Version = 1-0-0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.