Skip to content

Commit 44f3236

Browse files
committed
removed unecessary ping call and fixed case where mcp server would love connection with Unity
The issue where MCP server cannot reconnect with Unity still remains
1 parent 50bf855 commit 44f3236

27 files changed

+277
-343
lines changed

Editor/UnityBridge/McpUnityEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void DrawServerTab()
111111
GUI.enabled = !mcpUnityServer.IsListening;
112112
if (GUILayout.Button("Start Server", GUILayout.Height(30)))
113113
{
114-
mcpUnityServer.StopServer();
114+
mcpUnityServer.StartServer();
115115
}
116116

117117
// Disconnect button - enabled only when connected

Editor/UnityBridge/McpUnitySocketHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ protected override async void OnMessage(MessageEventArgs e)
6464
{
6565
responseJson = CreateErrorResponse("Missing method in request", "invalid_request");
6666
}
67-
else if (method == "ping")
68-
{
69-
// Handle MCP Protocol ping request - respond with an empty result object
70-
responseJson = new JObject();
71-
}
7267
else if (_server.TryGetTool(method, out var tool))
7368
{
7469
// Execute the tool

Server/build/resources/getAssetsResource.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export function createGetAssetsResource(mcpUnity, logger) {
1313
handler: async (params) => {
1414
const assetType = params?.assetType;
1515
const searchPattern = params?.searchPattern;
16-
logger.info(`Fetching assets from Asset Database${assetType ? ` of type ${assetType}` : ''}${searchPattern ? ` matching ${searchPattern}` : ''}`);
17-
if (!mcpUnity.isConnected) {
18-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
19-
}
2016
const response = await mcpUnity.sendRequest({
2117
method: resourceName,
2218
params: {

Server/build/resources/getConsoleLogResource.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export function createGetConsoleLogsResource(mcpUnity, logger) {
1111
mimeType: resourceMimeType
1212
},
1313
handler: async (params) => {
14-
logger.info(`Fetching Unity console logs`, params);
15-
if (!mcpUnity.isConnected) {
16-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
17-
}
1814
const response = await mcpUnity.sendRequest({
1915
method: resourceName,
2016
params: {}

Server/build/resources/getHierarchyResource.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export function createGetHierarchyResource(mcpUnity, logger) {
1111
mimeType: resourceMimeType
1212
},
1313
handler: async (params) => {
14-
logger.info(`Fetching Unity hierarchy`, params);
15-
if (!mcpUnity.isConnected) {
16-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
17-
}
1814
const response = await mcpUnity.sendRequest({
1915
method: resourceName,
2016
params: {}

Server/build/resources/getMenuItemResource.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ export function createGetMenuItemsResource(mcpUnity, logger) {
1111
mimeType: resourceMimeType
1212
},
1313
handler: async (params) => {
14-
logger.info(`Fetching menu items list`, params);
15-
if (!mcpUnity.isConnected) {
16-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
17-
}
1814
const response = await mcpUnity.sendRequest({
1915
method: resourceName,
2016
params: {}
2117
});
2218
if (!response.success) {
2319
throw new McpUnityError(ErrorType.RESOURCE_FETCH, response.message || 'Failed to fetch menu items from Unity');
2420
}
21+
logger.info(`Fetching resource:`, response.menuItems);
2522
return {
2623
contents: [{
2724
uri: resourceUri,

Server/build/resources/getPackagesResource.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export function createGetPackagesResource(mcpUnity, logger) {
1111
mimeType: resourceMimeType
1212
},
1313
handler: async (params) => {
14-
logger.info('Fetching package list from Unity Package Manager');
15-
if (!mcpUnity.isConnected) {
16-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
17-
}
1814
const response = await mcpUnity.sendRequest({
1915
method: resourceName,
2016
params: {}

Server/build/resources/getTestsResource.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ export function createGetTestsResource(mcpUnity, logger) {
77
uri: `unity://${resourceName}`,
88
handler: async (params) => {
99
const { testMode, nameFilter } = params;
10-
logger.info(`Fetching tests with filters: Mode=${testMode || 'All'}, Name=${nameFilter || 'none'}`);
11-
if (!mcpUnity.isConnected) {
12-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
13-
}
1410
const response = await mcpUnity.sendRequest({
1511
method: resourceName,
1612
params: {

Server/build/tools/menuItemTool.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ export function createMenuItemTool(mcpUnity, logger) {
99
menuPath: z.string().describe('The path to the menu item to execute (e.g. "GameObject/Create Empty")')
1010
}),
1111
handler: async ({ menuPath }) => {
12-
logger.info(`Executing menu item: ${menuPath}`);
13-
if (!mcpUnity.isConnected) {
14-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
15-
}
1612
const response = await mcpUnity.sendRequest({
1713
method: toolName,
1814
params: { menuPath }

Server/build/tools/notifyMessageTool.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export function createNotifyMessageTool(mcpUnity, logger) {
1111
}),
1212
handler: async (params) => {
1313
const { message, type = 'info' } = params;
14-
logger.info(`Sending notification to Unity console: ${message} (${type})`);
15-
if (!mcpUnity.isConnected) {
16-
throw new McpUnityError(ErrorType.CONNECTION, 'Not connected to Unity. Please ensure Unity is running with the MCP Unity plugin enabled.');
17-
}
1814
// Send to Unity
1915
const response = await mcpUnity.sendRequest({
2016
method: toolName,

0 commit comments

Comments
 (0)