Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,11 @@ jobs:
cd src/Deckle.Web
docker build -t deckle-web:local .

- name: Build MCP container
run: |
cd src
docker build -f Deckle.MCP/Dockerfile -t deckle-mcp:local .

- name: Prepare docker-compose artifacts
run: |
# Copy template and replace environment variables with actual image names
cp docker-compose-artifacts/docker-compose.yaml docker-compose-artifacts/docker-compose.yaml.template
sed 's/\${API_IMAGE}/deckle-api:local/g; s/\${WEB_IMAGE}/deckle-web:local/g; s/\${MCP_IMAGE}/deckle-mcp:local/g' docker-compose-artifacts/docker-compose.yaml.template > docker-compose-artifacts/docker-compose.yaml
sed 's/\${API_IMAGE}/deckle-api:local/g; s/\${WEB_IMAGE}/deckle-web:local/g' docker-compose-artifacts/docker-compose.yaml.template > docker-compose-artifacts/docker-compose.yaml

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -205,15 +200,11 @@ jobs:
env:
RAILWAY_API_WEBHOOK_URL: ${{ secrets.RAILWAY_API_WEBHOOK_URL }}
RAILWAY_WEB_WEBHOOK_URL: ${{ secrets.RAILWAY_WEB_WEBHOOK_URL }}
RAILWAY_MCP_WEBHOOK_URL: ${{ secrets.RAILWAY_MCP_WEBHOOK_URL }}
run: |
echo "Triggering Railway API deployment..."
curl -f -X POST "$RAILWAY_API_WEBHOOK_URL" || echo "Warning: API webhook failed"

echo "Triggering Railway Web deployment..."
curl -f -X POST "$RAILWAY_WEB_WEBHOOK_URL" || echo "Warning: Web webhook failed"

echo "Triggering Railway MCP deployment..."
curl -f -X POST "$RAILWAY_MCP_WEBHOOK_URL" || echo "Warning: MCP webhook failed"

echo "Railway deployments triggered successfully"
25 changes: 0 additions & 25 deletions docker-compose-artifacts/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,6 @@ services:
condition: "service_started"
networks:
- "aspire"
mcp:
image: "${MCP_IMAGE}"
environment:
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true"
OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory"
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
HTTP_PORTS: "${MCP_PORT}"
ConnectionStrings__deckledb: "Host=postgres;Port=5432;Username=postgres;Password=${POSTGRES_PASSWORD};Database=deckledb"
DECKLEDB_HOST: "postgres"
DECKLEDB_PORT: "5432"
DECKLEDB_USERNAME: "postgres"
DECKLEDB_PASSWORD: "${POSTGRES_PASSWORD}"
DECKLEDB_URI: "postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/deckledb"
DECKLEDB_DATABASENAME: "deckledb"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://compose-dashboard:18889"
OTEL_EXPORTER_OTLP_PROTOCOL: "grpc"
OTEL_SERVICE_NAME: "mcp"
expose:
- "${MCP_PORT}"
depends_on:
postgres:
condition: "service_started"
networks:
- "aspire"
networks:
aspire:
driver: "bridge"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
using Deckle.API.Auth;
using Deckle.Domain.Data;
using Deckle.Domain.Entities;
using Deckle.MCP.Auth;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;

namespace Deckle.MCP.Tests.Auth;
namespace Deckle.API.Tests.Auth;

public class ApiKeyAuthenticationHandlerTests : IDisposable
{
Expand Down Expand Up @@ -49,7 +49,7 @@

var handler = new ApiKeyAuthenticationHandler(
optionsMock.Object,
new NullLoggerFactory(),

Check warning on line 52 in src/Deckle.API.Tests/Auth/ApiKeyAuthenticationHandlerTests.cs

View workflow job for this annotation

GitHub Actions / build-and-push

Call System.IDisposable.Dispose on object created by 'new NullLoggerFactory()' before all references to it are out of scope (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
UrlEncoder.Default,
_context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Security.Claims;
using System.Text.Json;
using Deckle.API.McpTools;
using Deckle.Domain.Data;
using Deckle.Domain.Entities;
using Deckle.MCP.Tools;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Moq;

namespace Deckle.MCP.Tests.Tools;
namespace Deckle.API.Tests.McpTools;

public class ComponentToolsTests : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Security.Claims;
using System.Text.Json;
using Deckle.API.McpTools;
using Deckle.Domain.Data;
using Deckle.Domain.Entities;
using Deckle.MCP.Tools;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Moq;

namespace Deckle.MCP.Tests.Tools;
namespace Deckle.API.Tests.McpTools;

public class DataSourceToolsTests : IDisposable
{
Expand Down Expand Up @@ -274,7 +274,7 @@
_context.ChangeTracker.Clear();
var updated = await _context.DataSources.FindAsync(ds.Id);
Assert.Equal(42, updated!.RowCount);
Assert.Equal(3, updated!.Headers.Count);

Check warning on line 277 in src/Deckle.API.Tests/McpTools/DataSourceToolsTests.cs

View workflow job for this annotation

GitHub Actions / build-and-push

Dereference of a possibly null reference.
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System.Security.Claims;
using System.Text.Json;
using Deckle.API.McpTools;
using Deckle.Domain.Data;
using Deckle.Domain.Entities;
using Deckle.MCP.Tools;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Moq;
using File = Deckle.Domain.Entities.File;

namespace Deckle.MCP.Tests.Tools;
namespace Deckle.API.Tests.McpTools;

public class FileToolsTests : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Security.Claims;
using System.Text.Json;
using Deckle.API.McpTools;
using Deckle.Domain.Data;
using Deckle.Domain.Entities;
using Deckle.MCP.Tools;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Moq;

namespace Deckle.MCP.Tests.Tools;
namespace Deckle.API.Tests.McpTools;

public class ProjectToolsTests : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;

namespace Deckle.MCP.Auth;
namespace Deckle.API.Auth;

public class ApiKeyAuthenticationHandler(
IOptionsMonitor<AuthenticationSchemeOptions> options,
Expand Down
7 changes: 7 additions & 0 deletions src/Deckle.API/Deckle.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
<UserSecretsId>c83e7564-be8d-476c-8dea-73ae93b7199e</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Deckle.API.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="13.1.1" />
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="1.3.0" />
<PackageReference Include="AWSSDK.S3" Version="4.0.18.6" />
<PackageReference Include="Exceptionless.AspNetCore" Version="6.1.0" />
<PackageReference Include="MediatR" Version="14.0.0" />
Expand Down
9 changes: 8 additions & 1 deletion src/Deckle.API/Extensions/AuthenticationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Security.Claims;
using Deckle.API.Auth;
using Deckle.API.DTOs;
using Deckle.API.Services;
using Microsoft.AspNetCore.Authentication;
Expand All @@ -21,7 +22,9 @@ public static IServiceCollection AddDeckleAuthentication(
options.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
})
.AddCookie(options => ConfigureCookieOptions(options, configuration, environment))
.AddGoogle(options => ConfigureGoogleOptions(options, configuration));
.AddGoogle(options => ConfigureGoogleOptions(options, configuration))
.AddScheme<AuthenticationSchemeOptions, ApiKeyAuthenticationHandler>(
ApiKeyAuthenticationHandler.SchemeName, null);

return services;
}
Expand All @@ -32,6 +35,10 @@ public static IServiceCollection AddDeckleAuthorization(this IServiceCollection
{
options.AddPolicy("AdminOnly", policy =>
policy.RequireRole("Administrator"));

options.AddPolicy("ApiKey", policy =>
policy.AddAuthenticationSchemes(ApiKeyAuthenticationHandler.SchemeName)
.RequireAuthenticatedUser());
});

return services;
Expand Down
15 changes: 15 additions & 0 deletions src/Deckle.API/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Deckle.API.Configurators;
using Deckle.API.McpTools;
using Deckle.API.Services;
using Deckle.API.Services.Email;
using Deckle.Domain.Entities;
Expand Down Expand Up @@ -92,6 +93,20 @@ public static IServiceCollection AddDeckleInfrastructure(
return services;
}

public static IServiceCollection AddDeckleMcpTools(this IServiceCollection services)
{
services.AddHttpContextAccessor();
services
.AddMcpServer()
.WithHttpTransport()
.WithTools<ProjectTools>()
.WithTools<ComponentTools>()
.WithTools<DataSourceTools>()
.WithTools<FileTools>();

return services;
}

public static IServiceCollection AddDeckleRateLimiting(this IServiceCollection services)
{
services.AddRateLimiter(options =>
Expand Down
3 changes: 3 additions & 0 deletions src/Deckle.API/Extensions/WebApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Exceptionless;
using Hangfire;
using Microsoft.EntityFrameworkCore;
using ModelContextProtocol.AspNetCore;
using Scalar.AspNetCore;

namespace Deckle.API.Extensions;
Expand Down Expand Up @@ -75,6 +76,8 @@ public static WebApplication MapDeckleEndpoints(this WebApplication app)
app.MapUserEndpoints();
app.MapApiKeyEndpoints();

app.MapMcp("/mcp").RequireAuthorization("ApiKey");

return app;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;

namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

public abstract class BaseMcpTool(AppDbContext db, IHttpContextAccessor httpContextAccessor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.EntityFrameworkCore;
using ModelContextProtocol.Server;

namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

[McpServerToolType]
public sealed class ComponentTools(AppDbContext db, IHttpContextAccessor httpContextAccessor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.EntityFrameworkCore;
using ModelContextProtocol.Server;

namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

[McpServerToolType]
public sealed class DataSourceTools(AppDbContext db, IHttpContextAccessor httpContextAccessor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.EntityFrameworkCore;
using ModelContextProtocol.Server;

namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

[McpServerToolType]
public sealed class FileTools(AppDbContext db, IHttpContextAccessor httpContextAccessor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

internal static class McpErrors
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.EntityFrameworkCore;
using ModelContextProtocol.Server;

namespace Deckle.MCP.Tools;
namespace Deckle.API.McpTools;

[McpServerToolType]
public sealed class ProjectTools(AppDbContext db, IHttpContextAccessor httpContextAccessor)
Expand Down
3 changes: 3 additions & 0 deletions src/Deckle.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
// Application services
builder.Services.AddDeckleApplicationServices();

// MCP tools
builder.Services.AddDeckleMcpTools();

// Exception tracking
builder.Services.AddExceptionlessIfConfigured(builder.Configuration);

Expand Down
8 changes: 0 additions & 8 deletions src/Deckle.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
service.Name = "api";
});

var mcp = builder.AddProject<Projects.Deckle_MCP>("mcp")
.WithReference(database)
.WaitFor(database)
.PublishAsDockerComposeService((resource, service) =>
{
service.Name = "mcp";
});

web.WithReference(api)
.WithEnvironment("PUBLIC_API_URL", api.GetEndpoint("http"));

Expand Down
1 change: 0 additions & 1 deletion src/Deckle.AppHost/Deckle.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<ItemGroup>
<ProjectReference Include="..\Deckle.API\Deckle.API.csproj" />
<ProjectReference Include="..\Deckle.MCP\Deckle.MCP.csproj" />
</ItemGroup>

</Project>
34 changes: 0 additions & 34 deletions src/Deckle.MCP.Tests/Deckle.MCP.Tests.csproj

This file was deleted.

26 changes: 0 additions & 26 deletions src/Deckle.MCP/Deckle.MCP.csproj

This file was deleted.

Loading
Loading