Skip to content

Commit 706223f

Browse files
Merge pull request #2 from CapulusCodeNinja/bugfix/1-Compatibility-Issue-with-Google-Antigravity-MCP-Integration
Bugfix 1 compatibility issue with google antigravity mcp integration
2 parents 0aa53d7 + 532c3e2 commit 706223f

File tree

9 files changed

+103
-43
lines changed

9 files changed

+103
-43
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
<PropertyGroup Label="Default Versioning">
4040
<!-- Default version for all projects (can be overridden per project) -->
41-
<VersionPrefix>1.1.2</VersionPrefix>
42-
<VersionSuffix>5</VersionSuffix>
41+
<VersionPrefix>1.1.3</VersionPrefix>
42+
<VersionSuffix>1</VersionSuffix>
4343

4444
<!-- Calculated version -->
4545
<Version Condition="'$(Version)' == ''">$(VersionPrefix).$(VersionSuffix)</Version>

README.md

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
![MCP Nexus Icon](https://github.com/CapulusCodeNinja/mcp_nexus/blob/main/images/mcp_nexus_small.png?raw=true)
66

7-
![Tests](https://img.shields.io/badge/tests-1249%20passing-brightgreen)
8-
![Coverage](https://img.shields.io/badge/coverage-86.9%25%20lines-green)
7+
![Tests](https://img.shields.io/badge/tests-1247%20passing-brightgreen)
8+
![Coverage](https://img.shields.io/badge/coverage-87.1%25%20lines-green)
99
![Build](https://img.shields.io/badge/build-passing-brightgreen)
1010
![License](https://img.shields.io/badge/license-Apache%202.0-blue)
1111

@@ -66,50 +66,83 @@ dotnet run --project nexus/nexus.csproj
6666

6767
### Cursor IDE Integration
6868

69-
Add to `.cursor/mcp.json`:
69+
#### STDIO Integration
70+
71+
![Cursor Stdio](https://github.com/CapulusCodeNinja/mcp_nexus/blob/main/images/integrations/Cursor_stdio.gif?raw=true)
7072

7173
```json
7274
{
7375
"mcpServers": {
74-
"mcp-nexus": {
76+
"mcp_nexus": {
77+
"type": "stdio",
7578
"command": "dotnet",
76-
"args": ["run", "--project", "C:\\path\\to\\mcp_nexus\\nexus\\nexus.csproj"],
77-
"type": "stdio"
79+
"args": [
80+
"run",
81+
"--project",
82+
"C:\\Sources\\Github\\CapulusCodeNinja\\mcp_nexus\\nexus\\nexus.csproj",
83+
"--",
84+
"--stdio"
85+
]
7886
}
7987
}
8088
}
8189
```
8290

83-
### Claude Desktop Integration
91+
#### HTTP Integration
8492

85-
Add to `claude_desktop_config.json`:
93+
![Cursor Http](https://github.com/CapulusCodeNinja/mcp_nexus/blob/main/images/integrations/Cursor_http.gif?raw=true)
8694

8795
```json
8896
{
8997
"mcpServers": {
9098
"mcp-nexus": {
91-
"command": "dotnet",
92-
"args": ["run", "--project", "C:\\path\\to\\mcp_nexus\\nexus\\nexus.csproj"],
93-
"cwd": "C:\\path\\to\\mcp_nexus"
99+
"url": "http://0.0.0.0:5511/",
100+
"headers": {
101+
"Content-Type": "application/json"
102+
}
94103
}
95104
}
96105
}
97106
```
98107

108+
### Google Antigravity Integration
109+
110+
#### STDIO Integration
99111

100-
### Integration using HTTP
112+
![Antigravity Stdio](https://github.com/CapulusCodeNinja/mcp_nexus/blob/main/images/integrations/Antigravity_stdio.gif?raw=true)
101113

102114
```json
103115
{
104-
"mcpServers": {
105-
"mcp-nexus": {
106-
"type": "http",
107-
"url": "http://0.0.0.0:5511/",
108-
"headers": {
109-
"Content-Type": "application/json"
110-
}
116+
"mcpServers": {
117+
"mcp_nexus": {
118+
"command": "C:\\Program Files\\dotnet\\dotnet.exe",
119+
"args": [
120+
"run",
121+
"--project",
122+
"C:\\Sources\\Github\\CapulusCodeNinja\\mcp_nexus\\nexus\\nexus.csproj",
123+
"--",
124+
"--stdio"
125+
]
126+
}
127+
},
128+
"inputs": []
129+
}
130+
```
131+
132+
#### HTTP Integration
133+
134+
![Antigravity Http](https://github.com/CapulusCodeNinja/mcp_nexus/blob/main/images/integrations/Antigravity_http.gif?raw=true)
135+
136+
```json
137+
{
138+
"mcpServers": {
139+
"mcp-nexus": {
140+
"serverUrl": "http://0.0.0.0:5511/",
141+
"headers": {
142+
"Content-Type": "application/json"
143+
}
144+
}
111145
}
112-
}
113146
}
114147
```
115148

11.6 MB
Loading
7.57 MB
Loading
14.5 MB
Loading
14.3 MB
Loading

nexus/Startup/StartupBanner.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,34 @@ public void DisplayBanner()
6767
/// </summary>
6868
private void DisplayStartupHeader()
6969
{
70+
var isStdioMode = m_CommandLineContext.IsStdioMode;
7071
var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "Unknown";
7172
var processId = Environment.ProcessId;
7273
var startTime = DateTime.Now;
73-
var host = Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.Split(':').LastOrDefault() ?? "0.0.0.0";
74-
var port = Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.Split(':').LastOrDefault() ?? "5511";
75-
var transportMode = "http";
74+
string host;
75+
string port;
76+
string transportMode;
77+
78+
if (isStdioMode)
79+
{
80+
transportMode = "stdio";
81+
host = "stdio";
82+
port = "n/a";
83+
}
84+
else
85+
{
86+
transportMode = "http";
87+
88+
// Prefer configuration for host/port; fall back to ASPNETCORE_URLS when available.
89+
var sharedConfiguration = m_Settings.Get();
90+
var configuredHost = sharedConfiguration.McpNexus.Server.Host;
91+
var configuredPort = sharedConfiguration.McpNexus.Server.Port;
92+
93+
host = configuredHost ?? "0.0.0.0";
94+
port = configuredPort > 0
95+
? configuredPort.ToString(System.Globalization.CultureInfo.InvariantCulture)
96+
: (Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.Split(':').LastOrDefault() ?? "5511");
97+
}
7698

7799
m_Logger.Info("╔═══════════════════════════════════════════════════════════════════╗");
78100
m_Logger.Info(" MCP NEXUS STARTUP");

nexus_config/Internal/LoggingConfiguration.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public virtual void ConfigureLogging(ILoggingBuilder logging, bool isServiceMode
2424
var logLevel = GetLogLevelFromConfiguration();
2525
ConfigureNLogDynamically(logLevel, isServiceMode);
2626
ConfigureNLogProvider(logging, logLevel);
27+
28+
// Prevent any console-based providers from emitting noisy logs that would interfere
29+
// with MCP stdio communication. These filters ensure that even if a console logger
30+
// is added by hosting infrastructure, the most verbose categories are suppressed.
31+
_ = logging.AddFilter("ModelContextProtocol.Server.StdioServerTransport", Microsoft.Extensions.Logging.LogLevel.None);
32+
_ = logging.AddFilter("ModelContextProtocol.Server.McpServer", Microsoft.Extensions.Logging.LogLevel.None);
33+
_ = logging.AddFilter("Microsoft.Hosting.Lifetime", Microsoft.Extensions.Logging.LogLevel.None);
2734
}
2835

2936
/// <summary>
@@ -68,19 +75,6 @@ protected virtual void ConfigureNLogDynamically(Microsoft.Extensions.Logging.Log
6875
nlogConfig.LoggingRules.Add(new NLog.Config.LoggingRule("*", NLog.LogLevel.Info, NLog.LogLevel.Fatal, fileTarget));
6976
}
7077

71-
// Ensure stderr console target exists
72-
if (nlogConfig.FindTargetByName("stderr") is not NLog.Targets.ConsoleTarget)
73-
{
74-
var stderrTarget = new NLog.Targets.ConsoleTarget("stderr")
75-
{
76-
StdErr = true,
77-
Layout = "${longdate} [${level:uppercase=true}] ${message} ${exception:format=ToString}",
78-
Encoding = System.Text.Encoding.UTF8,
79-
};
80-
nlogConfig.AddTarget(stderrTarget);
81-
nlogConfig.LoggingRules.Add(new NLog.Config.LoggingRule("*", NLog.LogLevel.Info, NLog.LogLevel.Fatal, stderrTarget));
82-
}
83-
8478
// Apply service-mode paths (ProgramData vs app dir)
8579
ConfigureLogPaths(nlogConfig, isServiceMode);
8680

@@ -182,18 +176,22 @@ protected virtual void SetInternalLogFile(bool isServiceMode)
182176

183177
/// <summary>
184178
/// Configures the NLog provider for Microsoft.Extensions.Logging.
179+
/// Ensures that all framework logging is routed through NLog so that no logs
180+
/// are written directly to stdout. This is critical for MCP stdio mode where
181+
/// stdout must be reserved exclusively for JSON-RPC messages and all human-readable
182+
/// logging must go to file targets (or explicitly configured sinks).
185183
/// </summary>
186184
/// <param name="logging">The logging builder to configure.</param>
187185
/// <param name="logLevel">The log level to set.</param>
188186
protected virtual void ConfigureNLogProvider(ILoggingBuilder logging, Microsoft.Extensions.Logging.LogLevel logLevel)
189187
{
190-
// Only configure NLog for Microsoft.Extensions.Logging when Trace is enabled
191-
if (logLevel != Microsoft.Extensions.Logging.LogLevel.Trace)
192-
{
193-
return;
194-
}
188+
ArgumentNullException.ThrowIfNull(logging);
195189

190+
// Remove default console/debug providers so nothing writes directly to stdout/stderr.
196191
_ = logging.ClearProviders();
192+
193+
// Route Microsoft.Extensions.Logging through NLog (using NLog.Web for compatibility
194+
// with both generic hosts and ASP.NET Core).
197195
_ = logging.AddNLogWeb();
198196
_ = logging.SetMinimumLevel(logLevel);
199197
}

unittests/nexus_config_unittests/SettingsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using FluentAssertions;
22

3+
using Microsoft.Extensions.DependencyInjection;
34
using Microsoft.Extensions.Logging;
45

56
using Moq;
@@ -181,7 +182,9 @@ public void ConfigureLogging_WithServiceModeFalse_ConfiguresLogging()
181182
// Arrange
182183
m_Settings = new Settings();
183184
m_Settings.LoadConfiguration();
185+
var services = new ServiceCollection();
184186
var mockLoggingBuilder = new Mock<ILoggingBuilder>();
187+
_ = mockLoggingBuilder.SetupGet(builder => builder.Services).Returns(services);
185188
var isServiceMode = false;
186189

187190
// Act
@@ -200,7 +203,9 @@ public void ConfigureLogging_WithServiceModeTrue_ConfiguresLogging()
200203
// Arrange
201204
m_Settings = new Settings();
202205
m_Settings.LoadConfiguration();
206+
var services = new ServiceCollection();
203207
var mockLoggingBuilder = new Mock<ILoggingBuilder>();
208+
_ = mockLoggingBuilder.SetupGet(builder => builder.Services).Returns(services);
204209
var isServiceMode = true;
205210

206211
// Act
@@ -218,7 +223,9 @@ public void ConfigureLogging_AfterConstructor_ConfiguresLogging()
218223
{
219224
// Arrange
220225
m_Settings = new Settings();
226+
var services = new ServiceCollection();
221227
var mockLoggingBuilder = new Mock<ILoggingBuilder>();
228+
_ = mockLoggingBuilder.SetupGet(builder => builder.Services).Returns(services);
222229
var isServiceMode = false;
223230

224231
// Act - should work since constructor creates ConfigurationLoader

0 commit comments

Comments
 (0)