Skip to content

Commit

Permalink
fix: Stdio and SSE example, improve logging (#32)
Browse files Browse the repository at this point in the history
* fix: Examples stdio and sse
* fix: log message
  • Loading branch information
jirispilka authored Feb 7, 2025
1 parent 560e33b commit 1b1852c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/examples/clientSse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const dirname = path.dirname(filename);
dotenv.config({ path: path.resolve(dirname, '../../.env') });

const SERVER_URL = 'https://actors-mcp-server.apify.actor/sse';
// We need to change forward slash / to underscore _ in the tool name as Anthropic does not allow forward slashes in the tool name
const SELECTED_TOOL = 'apify_rag-web-browser';
// We need to change forward slash / to underscore -- in the tool name as Anthropic does not allow forward slashes in the tool name
const SELECTED_TOOL = 'apify--rag-web-browser';
const QUERY = 'web browser for Anthropic';

if (!process.env.APIFY_TOKEN) {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/clientStdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which node').toString().trim();

const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';
const SELECTED_TOOL = 'apify_rag-web-browser'; // We need to change / to _ in the tool name
const SELECTED_TOOL = 'apify--rag-web-browser'; // We need to change / to _ in the tool name

if (!process.env.APIFY_TOKEN) {
console.error('APIFY_TOKEN is required but not set in the environment variables.');
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ app.route(Routes.ROOT)
return;
}
try {
log.info(`Received GET message at: ${req.url}`);
log.info(`Received GET message at: ${Routes.ROOT}`);
await processParamsAndUpdateTools(req.url);
res.status(200).json({ message: `Actor is using Model Context Protocol. ${HELP_MESSAGE}` }).end();
} catch (error) {
Expand All @@ -76,7 +76,7 @@ app.route(Routes.ROOT)
app.route(Routes.SSE)
.get(async (req: Request, res: Response) => {
try {
log.info(`Received GET message at: ${req.url}`);
log.info(`Received GET message at: ${Routes.SSE}`);
await processParamsAndUpdateTools(req.url);
transport = new SSEServerTransport(Routes.MESSAGE, res);
await mcpServer.connect(transport);
Expand All @@ -89,7 +89,7 @@ app.route(Routes.SSE)
app.route(Routes.MESSAGE)
.post(async (req: Request, res: Response) => {
try {
log.info(`Received POST message at: ${req.url}`);
log.info(`Received POST message at: ${Routes.MESSAGE}`);
if (transport) {
await transport.handlePostMessage(req, res);
} else {
Expand Down

0 comments on commit 1b1852c

Please sign in to comment.