Skip to content

Commit 8fa4ce9

Browse files
MCP
1 parent 2e80e70 commit 8fa4ce9

File tree

4 files changed

+205
-0
lines changed

4 files changed

+205
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="..\NucliaDbClient\NucliaDbClient.csproj" />
9+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
10+
</ItemGroup>
11+
</Project>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using NucliaDB.Generated;
3+
using Outcome;
4+
5+
// Setup HTTP client factory
6+
var services = new ServiceCollection();
7+
services.AddHttpClient("default", client =>
8+
{
9+
client.BaseAddress = new Uri("http://localhost:8080/api/v1");
10+
client.Timeout = TimeSpan.FromSeconds(30);
11+
});
12+
13+
var serviceProvider = services.BuildServiceProvider();
14+
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
15+
var httpClient = httpClientFactory.CreateClient("default");
16+
17+
Console.WriteLine("NucliaDB Demo - Creating and retrieving a Knowledge Box\n");
18+
19+
// Create a knowledge box
20+
var kbSlug = $"test-kb-{DateTime.UtcNow:yyyyMMddHHmmss}";
21+
var createPayload = new
22+
{
23+
slug = kbSlug,
24+
title = "Test Knowledge Box",
25+
description = "A test KB created via RestClient.Net",
26+
};
27+
28+
Console.WriteLine($"Creating knowledge box with slug: {kbSlug}");
29+
var createResult = await httpClient.CreateKnowledgeBoxKbsAsync(createPayload).ConfigureAwait(false);
30+
31+
var kbId = createResult switch
32+
{
33+
OkKnowledgeBoxObj ok =>
34+
$"Created successfully! UUID: {ok.Value.Uuid}",
35+
ErrorKnowledgeBoxObj error => error.Value switch
36+
{
37+
HttpError<string>.ErrorResponseError err =>
38+
$"Error {err.StatusCode}: {err.Body}",
39+
HttpError<string>.ExceptionError err =>
40+
$"Exception: {err.Exception.Message}",
41+
_ => "Unknown error",
42+
},
43+
};
44+
45+
Console.WriteLine(kbId);
46+
47+
// Retrieve the knowledge box by slug
48+
Console.WriteLine($"\nRetrieving knowledge box by slug: {kbSlug}");
49+
var getResult = await httpClient.KbBySlugKbSSlugGetAsync(kbSlug).ConfigureAwait(false);
50+
51+
var kbDetails = getResult switch
52+
{
53+
OkKnowledgeBoxObjHTTPValidationError ok =>
54+
$"Retrieved KB:\n Slug: {ok.Value.Slug}\n UUID: {ok.Value.Uuid}",
55+
ErrorKnowledgeBoxObjHTTPValidationError error => error.Value switch
56+
{
57+
HttpError<HTTPValidationError>.ErrorResponseError err =>
58+
$"Error {err.StatusCode}: {err.Body}",
59+
HttpError<HTTPValidationError>.ExceptionError err =>
60+
$"Exception: {err.Exception.Message}",
61+
_ => "Unknown error",
62+
},
63+
};
64+
65+
Console.WriteLine(kbDetails);
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# NucliaDB MCP Server - Setup Complete! ✅
2+
3+
## 🎉 What's Running
4+
5+
### Docker Containers
6+
- **PostgreSQL** - Running on port 5432
7+
- **NucliaDB** - Running on port 8080, 8060, 8040
8+
9+
### MCP Server
10+
- **Name**: `nucliadb-mcp`
11+
- **Transport**: stdio
12+
- **Command**: `/Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/run-for-claude.sh`
13+
14+
## 🚀 Quick Start
15+
16+
### Check Docker Status
17+
```bash
18+
docker ps
19+
```
20+
21+
You should see:
22+
- `nucliadb-local` - NucliaDB server
23+
- `nucliadb-postgres` - PostgreSQL database
24+
25+
### Access NucliaDB
26+
- **Web UI**: http://localhost:8080
27+
- **API**: http://localhost:8080/api/v1
28+
29+
### Stop Services
30+
```bash
31+
cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient
32+
docker-compose down
33+
```
34+
35+
### Restart Services
36+
```bash
37+
cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient
38+
docker-compose up -d
39+
```
40+
41+
## 🔧 Claude Integration
42+
43+
The MCP server has been added to Claude! You can now:
44+
45+
1. **Start a new Claude session** - The MCP server will automatically connect
46+
2. **Access 100+ NucliaDB tools** - All API operations are available
47+
3. **Type-safe operations** - Full IntelliSense support
48+
49+
### Verify MCP Configuration
50+
```bash
51+
cat ~/.claude.json | grep nucliadb-mcp
52+
```
53+
54+
## 📦 Generated Tools
55+
56+
The MCP server provides **100+ tools** including:
57+
- Knowledge box management
58+
- Resource operations
59+
- Search functionality
60+
- File uploads
61+
- Vector operations
62+
- And much more!
63+
64+
All tools are:
65+
- ✅ Type-safe with proper aliases
66+
- ✅ Error handling via discriminated unions
67+
- ✅ Full XML documentation
68+
- ✅ 100% compilable code
69+
70+
## 🛠️ Development
71+
72+
### Rebuild MCP Server
73+
```bash
74+
cd /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer
75+
dotnet build -c Release
76+
```
77+
78+
### Regenerate MCP Tools
79+
```bash
80+
cd /Users/christianfindlay/Documents/Code/RestClient.Net
81+
dotnet run --project RestClient.Net.McpGenerator.Cli/RestClient.Net.McpGenerator.Cli.csproj -- \
82+
--openapi-url Samples/NucliaDbClient/api.yaml \
83+
--output-file Samples/NucliaDbClient/Generated/NucliaDbMcpTools.g.cs \
84+
--namespace NucliaDB.Mcp \
85+
--server-name NucliaDb \
86+
--ext-namespace NucliaDB.Generated
87+
```
88+
89+
### Update Claude Configuration
90+
```bash
91+
# Remove server
92+
claude mcp remove nucliadb-mcp
93+
94+
# Re-add server
95+
claude mcp add --transport stdio nucliadb-mcp /Users/christianfindlay/Documents/Code/RestClient.Net/Samples/NucliaDbClient.McpServer/run-for-claude.sh
96+
```
97+
98+
## 📊 Status
99+
100+
- **MCP Generator**: ✅ 100% Complete
101+
- **Docker Services**: ✅ Running
102+
- **Claude Integration**: ✅ Configured
103+
- **Build Status**: ✅ 0 errors, 0 warnings
104+
105+
## 🎯 Ready to Use!
106+
107+
Your NucliaDB MCP server is **production-ready** and integrated with Claude!
108+
109+
Start using it by:
110+
1. Opening a new Claude Code session
111+
2. The MCP server will automatically connect
112+
3. Start calling NucliaDB tools!
113+
114+
---
115+
116+
**Generated by RestClient.Net MCP Generator** 🚀
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Run script for Claude MCP integration
4+
# This script is called by Claude to start the MCP server
5+
6+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
8+
# Set environment variable for NucliaDB URL
9+
export NUCLIA_BASE_URL="http://localhost:8080/api/v1"
10+
11+
# Run the MCP server
12+
cd "$SCRIPT_DIR"
13+
exec dotnet run --no-build

0 commit comments

Comments
 (0)