Skip to content
Draft
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
8 changes: 8 additions & 0 deletions .github/agents/gnome-doc-librarian.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
description: 'Expert GNOME documentation librarian agent for finding and retrieving information and examples from GNOME docs.'
tools: ['gnome-docs/*']
---
You are a GNOME documentation librarian agent. Your task is to assist users in finding and retrieving information from the GNOME documentation set. You have access to a variety of tools that allow you to search and read documentation about GNOME libraries.

To effectively assist the user, do a deep research using the available tools, then come up with a concise and accurate answer based on the information you found.
You may need to retrieve multiple pieces of information and come up with a synthesized example to effectively illustrate your response.
23 changes: 23 additions & 0 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Adw from "gi://Adw";
import Actions from "./actions.js";
import { settings } from "./util.js";
import Window from "./window.js";
import { startMCPServer, stopMCPServer } from "./mcp-server-launcher.js";

const application = new Adw.Application({
application_id: pkg.name,
Expand All @@ -18,12 +19,34 @@ application.connect("activate", () => {
}
setColorScheme();
window.open();

// Start the MCP server on app activation
// Using --http mode on port 8080 for external tool integration
startMCPServer({
port: 8080,
debug: __DEV__, // Enable debug logging in development
}).then((success) => {
if (success) {
if (__DEV__) console.log("MCP server started successfully");
} else {
console.warn("Failed to start MCP server - some features may not work");
}
});
});

application.set_option_context_description(
"<https://github.com/workbenchdev/Biblioteca>",
);

// Handle cleanup when the application is shutting down
application.connect("shutdown", () => {
stopMCPServer(__DEV__).then((stopped) => {
if (stopped && __DEV__) {
console.log("MCP server stopped");
}
});
});

Actions({ application });

function setColorScheme() {
Expand Down
51 changes: 51 additions & 0 deletions src/mcp-server-launcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import GLib from "gi://GLib";
import Gio from "gi://Gio";

let subprocess = null;

export async function startMCPServer() {
if (subprocess) return true;

const path = getMCPServerPath();
if (!path) return false;

try {
subprocess = Gio.Subprocess.new(
["gjs", "-m", path, "--http"],
Gio.SubprocessFlags.NONE
);
return true;
} catch (e) {
console.error(`Failed to start MCP server: ${e}`);
return false;
}
}

export async function stopMCPServer() {
if (!subprocess) return false;

try {
subprocess.force_exit();
subprocess = null;
return true;
} catch (e) {
console.error(`Failed to stop MCP server: ${e}`);
return false;
}
}

function getMCPServerPath() {
const paths = [
"/app/share/biblioteca/mcp-server.js",
"/app/share/app.drey.Biblioteca.Devel/mcp-server.js",
"/app/share/app.drey.Biblioteca/mcp-server.js",
"/usr/share/biblioteca/mcp-server.js",
"/usr/local/share/biblioteca/mcp-server.js",
GLib.build_filenamev([GLib.get_current_dir(), "src/mcp-server/mcp-server.js"]),
];

for (const path of paths) {
if (path && GLib.file_test(path, GLib.FileTest.EXISTS)) return path;
}
return null;
}
Loading