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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ignfab/geocontext",
"version": "0.8.0",
"version": "0.8.1",
"description": "An experimental MCP server providing spatial context for LLM.",
"type": "module",
"bin": {
Expand Down
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { MCPServer } from "mcp-framework";

import { dirname } from "path";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import { readFileSync } from "fs";

// Get the directory of the current module (dist directory)
const __dirname = dirname(fileURLToPath(import.meta.url));

// Get version from package.json
const pkgMetadata = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
const VERSION = pkgMetadata.version;

/**
* Available transports
*/
const TRANSPORTS : Record<string, any> = {
'stdio' : {
const TRANSPORTS: Record<string, any> = {
'stdio': {
type: "stdio"
},
'http' : {
'http': {
type: "http-stream",
options: {
port: 3000,
Expand All @@ -28,12 +33,14 @@ const TRANSPORTS : Record<string, any> = {
async function main() {
// get transport type from environment variable
const TRANSPORT_TYPE = process.env.TRANSPORT_TYPE || "stdio";
if ( TRANSPORT_TYPE !== "stdio" && TRANSPORT_TYPE !== "http" ){
if (TRANSPORT_TYPE !== "stdio" && TRANSPORT_TYPE !== "http") {
throw new Error(`Invalid transport type: ${TRANSPORT_TYPE}`);
}

// start MCP server
const mcpServer = new MCPServer({
name: 'geocontext',
version: VERSION,
basePath: __dirname,
transport: TRANSPORTS[TRANSPORT_TYPE],
});
Expand Down